summaryrefslogtreecommitdiff
path: root/app/models/member.rb
diff options
context:
space:
mode:
authorDmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>2016-03-28 18:25:57 +0200
committerDmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>2016-03-30 10:44:20 +0200
commit7ea1bcab45697556d4ffd79ab680872ed823d4a3 (patch)
tree0780c4e11a9c951942238fe500ea49ea199098d9 /app/models/member.rb
parent359157c097993a9b917ca590e128e85cf358d95d (diff)
downloadgitlab-ce-7ea1bcab45697556d4ffd79ab680872ed823d4a3.tar.gz
Create notification setting when membership created
Signed-off-by: Dmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>
Diffstat (limited to 'app/models/member.rb')
-rw-r--r--app/models/member.rb10
1 files changed, 10 insertions, 0 deletions
diff --git a/app/models/member.rb b/app/models/member.rb
index ca08007b7eb..177f37c3bbd 100644
--- a/app/models/member.rb
+++ b/app/models/member.rb
@@ -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