Commit 7ea1bcab authored by Dmitriy Zaporozhets's avatar Dmitriy Zaporozhets

Create notification setting when membership created

Signed-off-by: default avatarDmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>
parent 359157c0
......@@ -56,6 +56,7 @@ class Member < ActiveRecord::Base
before_validation :generate_invite_token, on: :create, if: -> (member) { member.invite_email.present? }
after_create :send_invite, if: :invite?
after_create :create_notification_setting, unless: :invite?
after_create :post_create_hook, unless: :invite?
after_update :post_update_hook, unless: :invite?
after_destroy :post_destroy_hook, unless: :invite?
......@@ -160,6 +161,15 @@ class Member < ActiveRecord::Base
send_invite
end
def create_notification_setting
notification_setting = user.notification_settings.find_or_initialize_by(source: source)
unless notification_setting.persisted?
notification_setting.set_defaults
notification_setting.save
end
end
private
def send_invite
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment