diff options
author | Valery Sizov <vsv2711@gmail.com> | 2015-03-15 18:17:12 +0200 |
---|---|---|
committer | Valery Sizov <vsv2711@gmail.com> | 2015-03-15 19:44:59 +0200 |
commit | 9698b36c1cd0808adb006593c0e8649cb42f3571 (patch) | |
tree | 16c87f6a1d742c4b7a939f38e45af66b995ba1d7 /app/services | |
parent | 606d24ff2df157ec70003132d1ead7a47dc32883 (diff) | |
download | gitlab-ce-9698b36c1cd0808adb006593c0e8649cb42f3571.tar.gz |
Subscription
Diffstat (limited to 'app/services')
-rw-r--r-- | app/services/notification_service.rb | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/app/services/notification_service.rb b/app/services/notification_service.rb index 0063b7ce40c..4fa775a28ce 100644 --- a/app/services/notification_service.rb +++ b/app/services/notification_service.rb @@ -314,6 +314,13 @@ class NotificationService end end + def reject_unsubscribed_users(recipients, target) + recipients.reject do |user| + subscribe = target.subscribes.find_by_user_id(user.id) + subscribe && !subscribe.subscribed + end + end + def new_resource_email(target, project, method) recipients = build_recipients(target, project) recipients.delete(target.author) @@ -361,10 +368,21 @@ class NotificationService recipients = reject_muted_users(recipients, project) recipients = reject_mention_users(recipients, project) + recipients = add_subscribers(recipients, project) recipients = recipients.concat(project_watchers(project)).uniq + recipients = reject_unsubscribed_users(recipients, target) recipients end + def add_subscribers(recipients, target) + subs = target.subscribes + if subs.any? + recipients.merge(subs.where("subscribed is true").map(&:user)) + else + recipients + end + end + def mailer Notify.delay end |