diff options
author | Nick Thomas <nick@gitlab.com> | 2016-08-13 00:54:32 +0300 |
---|---|---|
committer | Nick Thomas <nick@gitlab.com> | 2016-08-13 00:54:32 +0300 |
commit | 59bfa0809822c3dd257748197223809922ab5f80 (patch) | |
tree | 8c5d247402532e0995f7f9f25203c6e787c3ed74 /app/services/notification_service.rb | |
parent | b2828d4145ac01468a59b821ced29dd248526089 (diff) |
Send notification emails when users are newly mentioned in issue edits
Diffstat (limited to 'app/services/notification_service.rb')
-rw-r--r-- | app/services/notification_service.rb | 24 |
1 files changed, 23 insertions, 1 deletions
diff --git a/app/services/notification_service.rb b/app/services/notification_service.rb index ab6e51209ee..73df572514f 100644 --- a/app/services/notification_service.rb +++ b/app/services/notification_service.rb @@ -35,6 +35,20 @@ class NotificationService new_resource_email(issue, issue.project, :new_issue_email) end + # When issue text is updated, we should send an email to: + # + # * newly mentioned project team members with notification level higher than Participating + # + def new_mentions_in_issue(issue, new_mentioned_users, current_user) + new_mentions_in_resource_email( + issue, + issue.project, + new_mentioned_users, + current_user, + :new_mention_in_issue_email + ) + end + # When we close an issue we should send an email to: # # * issue author if their notification level is not Disabled @@ -177,7 +191,7 @@ class NotificationService # build notify method like 'note_commit_email' notify_method = "note_#{note.noteable_type.underscore}_email".to_sym - + recipients.each do |recipient| mailer.send(notify_method, recipient.id, note.id).deliver_later end @@ -471,6 +485,14 @@ class NotificationService end end + def new_mentions_in_resource_email(target, project, new_mentioned_users, current_user, method) + recipients = build_recipients(target, project, current_user) & new_mentioned_users + + recipients.each do |recipient| + mailer.send(method, recipient.id, target.id, current_user.id).deliver_later + end + end + def close_resource_email(target, project, current_user, method) action = method == :merged_merge_request_email ? "merge" : "close" recipients = build_recipients(target, project, current_user, action: action) |