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

factor out .notifiable_users

parent a4932d2d
......@@ -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)
......
......@@ -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?
......
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