summaryrefslogtreecommitdiff
path: root/app/services/notification_service.rb
diff options
context:
space:
mode:
Diffstat (limited to 'app/services/notification_service.rb')
-rw-r--r--app/services/notification_service.rb27
1 files changed, 24 insertions, 3 deletions
diff --git a/app/services/notification_service.rb b/app/services/notification_service.rb
index 72712afc07e..6697840cc26 100644
--- a/app/services/notification_service.rb
+++ b/app/services/notification_service.rb
@@ -312,6 +312,22 @@ class NotificationService
mailer.project_was_not_exported_email(current_user, project, errors).deliver_later
end
+ def pipeline_finished(pipeline, recipients = nil)
+ email_template = "pipeline_#{pipeline.status}_email"
+
+ return unless mailer.respond_to?(email_template)
+
+ recipients ||= build_recipients(
+ pipeline,
+ pipeline.project,
+ nil, # The acting user, who won't be added to recipients
+ action: pipeline.status).map(&:notification_email)
+
+ if recipients.any?
+ mailer.public_send(email_template, pipeline, recipients).deliver_later
+ end
+ end
+
protected
# Get project/group users with CUSTOM notification level
@@ -475,9 +491,14 @@ class NotificationService
end
def reject_users_without_access(recipients, target)
- return recipients unless target.is_a?(Issuable)
+ ability = case target
+ when Issuable
+ :"read_#{target.to_ability_name}"
+ when Ci::Pipeline
+ :read_build # We have build trace in pipeline emails
+ end
- ability = :"read_#{target.to_ability_name}"
+ return recipients unless ability
recipients.select do |user|
user.can?(ability, target)
@@ -624,6 +645,6 @@ class NotificationService
# Build event key to search on custom notification level
# Check NotificationSetting::EMAIL_EVENTS
def build_custom_key(action, object)
- "#{action}_#{object.class.name.underscore}".to_sym
+ "#{action}_#{object.class.model_name.name.underscore}".to_sym
end
end