Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorhttp://jneen.net/ <jneen@jneen.net>2017-07-26 18:36:49 +0300
committerhttp://jneen.net/ <jneen@jneen.net>2017-08-03 19:07:18 +0300
commit618b5d34463b1a54cca0d47d3d815b7e388a1db2 (patch)
treed21a06343cff8fc871bcd43f2c7afd5df42b90de /app/services/notification_service.rb
parent6aa44382acbe1439c48da056ab9089e36124878f (diff)
move the #build_* methods to static, parameterize the project
Diffstat (limited to 'app/services/notification_service.rb')
-rw-r--r--app/services/notification_service.rb24
1 files changed, 14 insertions, 10 deletions
diff --git a/app/services/notification_service.rb b/app/services/notification_service.rb
index 8a6ed88923d..675b4536a26 100644
--- a/app/services/notification_service.rb
+++ b/app/services/notification_service.rb
@@ -77,7 +77,8 @@ class NotificationService
# * users with custom level checked with "reassign issue"
#
def reassigned_issue(issue, current_user, previous_assignees = [])
- recipients = NotificationRecipientService.new(issue.project).build_recipients(
+ recipients = NotificationRecipientService.build_recipients(
+ issue.project,
issue,
current_user,
action: "reassign",
@@ -177,7 +178,8 @@ class NotificationService
end
def resolve_all_discussions(merge_request, current_user)
- recipients = NotificationRecipientService.new(merge_request.target_project).build_recipients(
+ recipients = NotificationRecipientService.build_recipients(
+ merge_request.target_project,
merge_request,
current_user,
action: "resolve_all_discussions")
@@ -202,7 +204,7 @@ class NotificationService
notify_method = "note_#{note.to_ability_name}_email".to_sym
- recipients = NotificationRecipientService.new(note.project).build_new_note_recipients(note)
+ recipients = NotificationRecipientService.build_new_note_recipients(note.project, note)
recipients.each do |recipient|
mailer.send(notify_method, recipient.id, note.id).deliver_later
end
@@ -282,7 +284,7 @@ class NotificationService
end
def issue_moved(issue, new_issue, current_user)
- recipients = NotificationRecipientService.new(issue.project).build_recipients(issue, current_user, action: 'moved')
+ recipients = NotificationRecipientService.build_recipients(issue.project, issue, current_user, action: 'moved')
recipients.map do |recipient|
email = mailer.issue_moved_email(recipient, issue, new_issue, current_user)
@@ -317,7 +319,7 @@ class NotificationService
protected
def new_resource_email(target, project, method)
- recipients = NotificationRecipientService.new(project).build_recipients(target, target.author, action: "new")
+ recipients = NotificationRecipientService.build_recipients(project, target, target.author, action: "new")
recipients.each do |recipient|
mailer.send(method, recipient.id, target.id).deliver_later
@@ -325,7 +327,7 @@ class NotificationService
end
def new_mentions_in_resource_email(target, project, new_mentioned_users, current_user, method)
- recipients = NotificationRecipientService.new(project).build_recipients(target, current_user, action: "new")
+ recipients = NotificationRecipientService.build_recipients(project, target, current_user, action: "new")
recipients = recipients & new_mentioned_users
recipients.each do |recipient|
@@ -336,7 +338,8 @@ class NotificationService
def close_resource_email(target, project, current_user, method, skip_current_user: true)
action = method == :merged_merge_request_email ? "merge" : "close"
- recipients = NotificationRecipientService.new(project).build_recipients(
+ recipients = NotificationRecipientService.build_recipients(
+ project,
target,
current_user,
action: action,
@@ -352,7 +355,8 @@ class NotificationService
previous_assignee_id = previous_record(target, 'assignee_id')
previous_assignee = User.find_by(id: previous_assignee_id) if previous_assignee_id
- recipients = NotificationRecipientService.new(project).build_recipients(
+ recipients = NotificationRecipientService.build_recipients(
+ project,
target,
current_user,
action: "reassign",
@@ -371,7 +375,7 @@ class NotificationService
end
def relabeled_resource_email(target, project, labels, current_user, method)
- recipients = NotificationRecipientService.new(project).build_relabeled_recipients(target, current_user, labels: labels)
+ recipients = NotificationRecipientService.build_relabeled_recipients(project, target, current_user, labels: labels)
label_names = labels.map(&:name)
recipients.each do |recipient|
@@ -380,7 +384,7 @@ class NotificationService
end
def reopen_resource_email(target, project, current_user, method, status)
- recipients = NotificationRecipientService.new(project).build_recipients(target, current_user, action: "reopen")
+ recipients = NotificationRecipientService.build_recipients(project, target, current_user, action: "reopen")
recipients.each do |recipient|
mailer.send(method, recipient.id, target.id, status, current_user.id).deliver_later