Commit 4caa5a7e authored by http://jneen.net/'s avatar http://jneen.net/

factor out .notifiable_users

parent a4932d2d
...@@ -378,38 +378,6 @@ class NotificationRecipientService ...@@ -378,38 +378,6 @@ class NotificationRecipientService
end end
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 class Relabeled < Base
attr_reader :project attr_reader :project
attr_reader :target attr_reader :target
...@@ -475,12 +443,12 @@ class NotificationRecipientService ...@@ -475,12 +443,12 @@ class NotificationRecipientService
end end
end end
def build_recipients(*a) def self.notifiable_users(*a)
Builder::Default.new(@project, *a).recipient_users Recipient.notifiable_users(*a)
end end
def build_pipeline_recipients(*a) def build_recipients(*a)
Builder::Pipeline.new(@project, *a).recipient_users Builder::Default.new(@project, *a).recipient_users
end end
def build_relabeled_recipients(*a) def build_relabeled_recipients(*a)
......
...@@ -270,7 +270,7 @@ class NotificationService ...@@ -270,7 +270,7 @@ class NotificationService
end end
def project_was_moved(project, old_path_with_namespace) 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| recipients.each do |recipient|
mailer.project_was_moved_email( mailer.project_was_moved_email(
...@@ -304,10 +304,9 @@ class NotificationService ...@@ -304,10 +304,9 @@ class NotificationService
return unless mailer.respond_to?(email_template) return unless mailer.respond_to?(email_template)
recipients ||= NotificationRecipientService.new(pipeline.project).build_pipeline_recipients( recipients ||= NotificationRecipientService.notifiable_users(
pipeline, [pipeline.user], pipeline.project, :watch,
pipeline.user, custom_action: :"#{pipeline.status}_pipeline"
action: pipeline.status
).map(&:notification_email) ).map(&:notification_email)
if recipients.any? if recipients.any?
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment