diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2019-10-17 21:08:05 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2019-10-17 21:08:05 +0300 |
commit | 184c2ced0761bd8dd7032619d16d3983fed7944a (patch) | |
tree | cc82b32ee7c1797509da3cf384617e4ffa2e1733 /app/services | |
parent | 238d22c07218adf2b8f3db630ee8b74ca6f29df5 (diff) |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'app/services')
-rw-r--r-- | app/services/notification_recipient_service.rb | 24 | ||||
-rw-r--r-- | app/services/notification_service.rb | 9 |
2 files changed, 33 insertions, 0 deletions
diff --git a/app/services/notification_recipient_service.rb b/app/services/notification_recipient_service.rb index fca64270cae..9afbb678f5d 100644 --- a/app/services/notification_recipient_service.rb +++ b/app/services/notification_recipient_service.rb @@ -28,6 +28,10 @@ module NotificationRecipientService Builder::ProjectMaintainers.new(*args).notification_recipients end + def self.build_new_release_recipients(*args) + Builder::NewRelease.new(*args).notification_recipients + end + module Builder class Base def initialize(*) @@ -359,6 +363,26 @@ module NotificationRecipientService end end + class NewRelease < Base + attr_reader :target + + def initialize(target) + @target = target + end + + def build! + add_recipients(target.project.authorized_users, :custom, nil) + end + + def custom_action + :new_release + end + + def acting_user + target.author + end + end + class MergeRequestUnmergeable < Base attr_reader :target def initialize(merge_request) diff --git a/app/services/notification_service.rb b/app/services/notification_service.rb index ed357aa0392..b56b2cf14e3 100644 --- a/app/services/notification_service.rb +++ b/app/services/notification_service.rb @@ -289,6 +289,15 @@ class NotificationService end end + # Notify users when a new release is created + def send_new_release_notifications(release) + recipients = NotificationRecipientService.build_new_release_recipients(release) + + recipients.each do |recipient| + mailer.new_release_email(recipient.user.id, release, recipient.reason).deliver_later + end + end + # Members def new_access_request(member) return true unless member.notifiable?(:subscription) |