diff options
author | http://jneen.net/ <jneen@jneen.net> | 2017-07-31 09:30:35 -0700 |
---|---|---|
committer | http://jneen.net/ <jneen@jneen.net> | 2017-08-03 09:07:18 -0700 |
commit | 19309b970556797027e57c212d9b9aa053c36892 (patch) | |
tree | 534566b686ad4d3de6ed075f2d11a5863ca4863b /app | |
parent | 3829d7245a446fe80745f5e7c082e005fc013365 (diff) | |
download | gitlab-ce-19309b970556797027e57c212d9b9aa053c36892.tar.gz |
default the project to target.project
Diffstat (limited to 'app')
-rw-r--r-- | app/models/notification_recipient.rb | 12 | ||||
-rw-r--r-- | app/services/notification_recipient_service.rb | 3 | ||||
-rw-r--r-- | app/services/notification_service.rb | 4 |
3 files changed, 13 insertions, 6 deletions
diff --git a/app/models/notification_recipient.rb b/app/models/notification_recipient.rb index 0b2eee56ff8..96e8e32c644 100644 --- a/app/models/notification_recipient.rb +++ b/app/models/notification_recipient.rb @@ -1,14 +1,20 @@ class NotificationRecipient attr_reader :user, :project, :type - def initialize(user, project, type, - custom_action: nil, target: nil, acting_user: nil, read_ability: nil) - @project = project + def initialize(user, type, + custom_action: nil, + target: nil, + acting_user: nil, + read_ability: nil, + project: nil) @custom_action = custom_action @acting_user = acting_user @read_ability = read_ability @target = target + @project = project || @target&.project @user = user @type = type + + raise ArgumentError, "Project is missing" if @project.nil? end def notification_setting diff --git a/app/services/notification_recipient_service.rb b/app/services/notification_recipient_service.rb index 6b4e97aaab4..0627cca9214 100644 --- a/app/services/notification_recipient_service.rb +++ b/app/services/notification_recipient_service.rb @@ -56,7 +56,8 @@ module NotificationRecipientService end def make_recipient(user, type) - NotificationRecipient.new(user, project, type, + NotificationRecipient.new(user, type, + project: project, custom_action: custom_action, target: target, acting_user: acting_user, diff --git a/app/services/notification_service.rb b/app/services/notification_service.rb index e9a67cac4d6..f5366b9ceab 100644 --- a/app/services/notification_service.rb +++ b/app/services/notification_service.rb @@ -272,7 +272,7 @@ class NotificationService end def project_was_moved(project, old_path_with_namespace) - recipients = NotificationRecipientService.notifiable_users(project.team.members, project, :mention) + recipients = NotificationRecipientService.notifiable_users(project.team.members, :mention, project: project) recipients.each do |recipient| mailer.project_was_moved_email( @@ -307,7 +307,7 @@ class NotificationService return unless mailer.respond_to?(email_template) recipients ||= NotificationRecipientService.notifiable_users( - [pipeline.user], pipeline.project, :watch, + [pipeline.user], :watch, custom_action: :"#{pipeline.status}_pipeline", read_ability: :read_build, target: pipeline |