diff options
author | http://jneen.net/ <jneen@jneen.net> | 2017-07-26 18:25:29 +0300 |
---|---|---|
committer | http://jneen.net/ <jneen@jneen.net> | 2017-08-03 19:06:15 +0300 |
commit | 4caa5a7e14a8aa1e973662bd1394468eac74f3ad (patch) | |
tree | bd8d1b94b81c34eddb16abb2f553ff59610787d6 /app/services | |
parent | a4932d2da72af14eeea99e466117bdb767d111c7 (diff) |
factor out .notifiable_users
Diffstat (limited to 'app/services')
-rw-r--r-- | app/services/notification_recipient_service.rb | 40 | ||||
-rw-r--r-- | app/services/notification_service.rb | 9 |
2 files changed, 8 insertions, 41 deletions
diff --git a/app/services/notification_recipient_service.rb b/app/services/notification_recipient_service.rb index 20d8a06903c..3d36660495f 100644 --- a/app/services/notification_recipient_service.rb +++ b/app/services/notification_recipient_service.rb @@ -378,38 +378,6 @@ class NotificationRecipientService end end - class Pipeline < Base - attr_reader :project - attr_reader :target - attr_reader :current_user - attr_reader :action - def initialize(project, target, current_user, action:) - @project = project - @target = target - @current_user = current_user - @action = action - end - - def acting_user - nil - end - - def custom_action - case action.to_s - when 'failed' - :failed_pipeline - when 'success' - :success_pipeline - end - end - - def build! - return [] unless current_user - - self << [current_user, :watch] - end - end - class Relabeled < Base attr_reader :project attr_reader :target @@ -475,12 +443,12 @@ class NotificationRecipientService end end - def build_recipients(*a) - Builder::Default.new(@project, *a).recipient_users + def self.notifiable_users(*a) + Recipient.notifiable_users(*a) end - def build_pipeline_recipients(*a) - Builder::Pipeline.new(@project, *a).recipient_users + def build_recipients(*a) + Builder::Default.new(@project, *a).recipient_users end def build_relabeled_recipients(*a) diff --git a/app/services/notification_service.rb b/app/services/notification_service.rb index a094d97a295..8a6ed88923d 100644 --- a/app/services/notification_service.rb +++ b/app/services/notification_service.rb @@ -270,7 +270,7 @@ class NotificationService end def project_was_moved(project, old_path_with_namespace) - recipients = NotificationRecipientService::Recipient.notifiable_users(project.team.members, project, :watch) + recipients = NotificationRecipientService.notifiable_users(project.team.members, project, :mention) recipients.each do |recipient| mailer.project_was_moved_email( @@ -304,10 +304,9 @@ class NotificationService return unless mailer.respond_to?(email_template) - recipients ||= NotificationRecipientService.new(pipeline.project).build_pipeline_recipients( - pipeline, - pipeline.user, - action: pipeline.status + recipients ||= NotificationRecipientService.notifiable_users( + [pipeline.user], pipeline.project, :watch, + custom_action: :"#{pipeline.status}_pipeline" ).map(&:notification_email) if recipients.any? |