diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2020-06-18 14:18:50 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2020-06-18 14:18:50 +0300 |
commit | 8c7f4e9d5f36cff46365a7f8c4b9c21578c1e781 (patch) | |
tree | a77e7fe7a93de11213032ed4ab1f33a3db51b738 /app/services/notification_service.rb | |
parent | 00b35af3db1abfe813a778f643dad221aad51fca (diff) |
Add latest changes from gitlab-org/gitlab@13-1-stable-ee
Diffstat (limited to 'app/services/notification_service.rb')
-rw-r--r-- | app/services/notification_service.rb | 29 |
1 files changed, 24 insertions, 5 deletions
diff --git a/app/services/notification_service.rb b/app/services/notification_service.rb index 4c1db03fab8..73e60ac8420 100644 --- a/app/services/notification_service.rb +++ b/app/services/notification_service.rb @@ -68,10 +68,10 @@ class NotificationService # Notify a user when a previously unknown IP or device is used to # sign in to their account - def unknown_sign_in(user, ip) + def unknown_sign_in(user, ip, time) return unless user.can?(:receive_notifications) - mailer.unknown_sign_in_email(user, ip).deliver_later + mailer.unknown_sign_in_email(user, ip, time).deliver_later end # When create an issue we should send an email to: @@ -447,14 +447,14 @@ class NotificationService # from the PipelinesEmailService integration. return if pipeline.project.emails_disabled? - ref_status ||= pipeline.status - email_template = "pipeline_#{ref_status}_email" + status = pipeline_notification_status(ref_status, pipeline) + email_template = "pipeline_#{status}_email" return unless mailer.respond_to?(email_template) recipients ||= notifiable_users( [pipeline.user], :watch, - custom_action: :"#{ref_status}_pipeline", + custom_action: :"#{status}_pipeline", target: pipeline ).map do |user| user.notification_email_for(pipeline.project.group) @@ -557,6 +557,15 @@ class NotificationService mailer.group_was_not_exported_email(current_user, group, errors).deliver_later end + # Notify users on new review in system + def new_review(review) + recipients = NotificationRecipients::BuildService.build_new_review_recipients(review) + + recipients.each do |recipient| + mailer.new_review_email(recipient.user.id, review.id).deliver_later + end + end + protected def new_resource_email(target, method) @@ -652,6 +661,16 @@ class NotificationService private + def pipeline_notification_status(ref_status, pipeline) + if Ci::Ref.failing_state?(ref_status) + 'failed' + elsif ref_status + ref_status + else + pipeline.status + end + end + def owners_and_maintainers_without_invites(project) recipients = project.members.active_without_invites_and_requests.owners_and_maintainers |