diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2023-01-21 03:08:59 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2023-01-21 03:08:59 +0300 |
commit | 367847e266036617e540e41b7fd3c7d03033800c (patch) | |
tree | a14547ad7556d48dcdeb977021f8cd89305ea026 /app/services/notification_service.rb | |
parent | 5d7e5a8902382caaffa616e1b496b684ba72d148 (diff) |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'app/services/notification_service.rb')
-rw-r--r-- | app/services/notification_service.rb | 78 |
1 files changed, 38 insertions, 40 deletions
diff --git a/app/services/notification_service.rb b/app/services/notification_service.rb index 777d02c590d..1be240356c6 100644 --- a/app/services/notification_service.rb +++ b/app/services/notification_service.rb @@ -212,14 +212,6 @@ class NotificationService relabeled_resource_email(issue, added_labels, current_user, :relabeled_issue_email) end - def removed_milestone_issue(issue, current_user) - removed_milestone_resource_email(issue, current_user, :removed_milestone_issue_email) - end - - def changed_milestone_issue(issue, new_milestone, current_user) - changed_milestone_resource_email(issue, new_milestone, current_user, :changed_milestone_issue_email) - end - # When create a merge request we should send an email to: # # * mr author @@ -366,14 +358,6 @@ class NotificationService relabeled_resource_email(merge_request, added_labels, current_user, :relabeled_merge_request_email) end - def removed_milestone_merge_request(merge_request, current_user) - removed_milestone_resource_email(merge_request, current_user, :removed_milestone_merge_request_email) - end - - def changed_milestone_merge_request(merge_request, new_milestone, current_user) - changed_milestone_resource_email(merge_request, new_milestone, current_user, :changed_milestone_merge_request_email) - end - def close_mr(merge_request, current_user) close_resource_email(merge_request, current_user, :closed_merge_request_email) end @@ -788,6 +772,44 @@ class NotificationService end end + def removed_milestone(target, current_user) + method = case target + when Issue + :removed_milestone_issue_email + when MergeRequest + :removed_milestone_merge_request_email + end + + recipients = NotificationRecipients::BuildService.build_recipients( + target, + current_user, + action: 'removed_milestone' + ) + + recipients.each do |recipient| + mailer.send(method, recipient.user.id, target.id, current_user.id).deliver_later + end + end + + def changed_milestone(target, milestone, current_user) + method = case target + when Issue + :changed_milestone_issue_email + when MergeRequest + :changed_milestone_merge_request_email + end + + recipients = NotificationRecipients::BuildService.build_recipients( + target, + current_user, + action: 'changed_milestone' + ) + + recipients.each do |recipient| + mailer.send(method, recipient.user.id, target.id, milestone, current_user.id).deliver_later + end + end + protected def new_resource_email(target, current_user, method) @@ -847,30 +869,6 @@ class NotificationService end end - def removed_milestone_resource_email(target, current_user, method) - recipients = NotificationRecipients::BuildService.build_recipients( - target, - current_user, - action: 'removed_milestone' - ) - - recipients.each do |recipient| - mailer.send(method, recipient.user.id, target.id, current_user.id).deliver_later - end - end - - def changed_milestone_resource_email(target, milestone, current_user, method) - recipients = NotificationRecipients::BuildService.build_recipients( - target, - current_user, - action: 'changed_milestone' - ) - - recipients.each do |recipient| - mailer.send(method, recipient.user.id, target.id, milestone, current_user.id).deliver_later - end - end - def reopen_resource_email(target, current_user, method, status) recipients = NotificationRecipients::BuildService.build_recipients(target, current_user, action: "reopen") |