summaryrefslogtreecommitdiff
path: root/app/mailers
diff options
context:
space:
mode:
authorGitLab Bot <gitlab-bot@gitlab.com>2019-11-12 21:06:30 +0000
committerGitLab Bot <gitlab-bot@gitlab.com>2019-11-12 21:06:30 +0000
commit6e3880e2bb5a404467c64edc916d9edf7556d09d (patch)
tree95cfb0de65623b7015b9d1a8c9ebb559a9358033 /app/mailers
parent6d31b8f052d30b7e55128d17b66bceed8c6065a9 (diff)
downloadgitlab-ce-6e3880e2bb5a404467c64edc916d9edf7556d09d.tar.gz
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'app/mailers')
-rw-r--r--app/mailers/emails/members.rb37
-rw-r--r--app/mailers/emails/pipelines.rb5
-rw-r--r--app/mailers/emails/releases.rb8
-rw-r--r--app/mailers/previews/notify_preview.rb6
4 files changed, 37 insertions, 19 deletions
diff --git a/app/mailers/emails/members.rb b/app/mailers/emails/members.rb
index ea8032324aa..06d2219d6a9 100644
--- a/app/mailers/emails/members.rb
+++ b/app/mailers/emails/members.rb
@@ -15,16 +15,18 @@ module Emails
user = User.find(recipient_id)
- mail(to: user.notification_email_for(notification_group),
- subject: subject("Request to join the #{member_source.human_name} #{member_source.model_name.singular}"))
+ member_email_with_layout(
+ to: user.notification_email_for(notification_group),
+ subject: subject("Request to join the #{member_source.human_name} #{member_source.model_name.singular}"))
end
def member_access_granted_email(member_source_type, member_id)
@member_source_type = member_source_type
@member_id = member_id
- mail(to: member.user.notification_email_for(notification_group),
- subject: subject("Access to the #{member_source.human_name} #{member_source.model_name.singular} was granted"))
+ member_email_with_layout(
+ to: member.user.notification_email_for(notification_group),
+ subject: subject("Access to the #{member_source.human_name} #{member_source.model_name.singular} was granted"))
end
def member_access_denied_email(member_source_type, source_id, user_id)
@@ -33,8 +35,9 @@ module Emails
user = User.find(user_id)
- mail(to: user.notification_email_for(notification_group),
- subject: subject("Access to the #{member_source.human_name} #{member_source.model_name.singular} was denied"))
+ member_email_with_layout(
+ to: user.notification_email_for(notification_group),
+ subject: subject("Access to the #{member_source.human_name} #{member_source.model_name.singular} was denied"))
end
def member_invited_email(member_source_type, member_id, token)
@@ -42,8 +45,9 @@ module Emails
@member_id = member_id
@token = token
- mail(to: member.invite_email,
- subject: subject("Invitation to join the #{member_source.human_name} #{member_source.model_name.singular}"))
+ member_email_with_layout(
+ to: member.invite_email,
+ subject: subject("Invitation to join the #{member_source.human_name} #{member_source.model_name.singular}"))
end
def member_invite_accepted_email(member_source_type, member_id)
@@ -51,8 +55,9 @@ module Emails
@member_id = member_id
return unless member.created_by
- mail(to: member.created_by.notification_email_for(notification_group),
- subject: subject('Invitation accepted'))
+ member_email_with_layout(
+ to: member.created_by.notification_email_for(notification_group),
+ subject: subject('Invitation accepted'))
end
def member_invite_declined_email(member_source_type, source_id, invite_email, created_by_id)
@@ -64,8 +69,9 @@ module Emails
user = User.find(created_by_id)
- mail(to: user.notification_email_for(notification_group),
- subject: subject('Invitation declined'))
+ member_email_with_layout(
+ to: user.notification_email_for(notification_group),
+ subject: subject('Invitation declined'))
end
def member
@@ -85,5 +91,12 @@ module Emails
def member_source_class
@member_source_type.classify.constantize
end
+
+ def member_email_with_layout(to:, subject:)
+ mail(to: to, subject: subject) do |format|
+ format.html { render layout: 'mailer' }
+ format.text { render layout: 'mailer' }
+ end
+ end
end
end
diff --git a/app/mailers/emails/pipelines.rb b/app/mailers/emails/pipelines.rb
index 34e12a5fa6d..95bb52d8f97 100644
--- a/app/mailers/emails/pipelines.rb
+++ b/app/mailers/emails/pipelines.rb
@@ -18,12 +18,11 @@ module Emails
@merge_request = pipeline.all_merge_requests.first
add_headers
- # We use bcc here because we don't want to generate this emails for a
+ # We use bcc here because we don't want to generate these emails for a
# thousand times. This could be potentially expensive in a loop, and
# recipients would contain all project watchers so it could be a lot.
mail(bcc: recipients,
- subject: pipeline_subject(status),
- skip_premailer: true) do |format|
+ subject: pipeline_subject(status)) do |format|
format.html { render layout: 'mailer' }
format.text { render layout: 'mailer' }
end
diff --git a/app/mailers/emails/releases.rb b/app/mailers/emails/releases.rb
index 137858d31e8..c9c77ab9333 100644
--- a/app/mailers/emails/releases.rb
+++ b/app/mailers/emails/releases.rb
@@ -21,7 +21,13 @@ module Emails
private
def release_email_subject
- release_info = [@release.name, @release.tag].select(&:presence).join(' - ')
+ release_info =
+ if @release.name == @release.tag
+ @release.tag
+ else
+ [@release.name, @release.tag].select(&:presence).join(' - ')
+ end
+
"New release: #{release_info}"
end
end
diff --git a/app/mailers/previews/notify_preview.rb b/app/mailers/previews/notify_preview.rb
index 3d42423ba46..381a4f54d9e 100644
--- a/app/mailers/previews/notify_preview.rb
+++ b/app/mailers/previews/notify_preview.rb
@@ -77,7 +77,7 @@ class NotifyPreview < ActionMailer::Preview
end
def import_issues_csv_email
- Notify.import_issues_csv_email(user, project, { success: 3, errors: [5, 6, 7], valid_file: true })
+ Notify.import_issues_csv_email(user.id, project.id, { success: 3, errors: [5, 6, 7], valid_file: true })
end
def closed_merge_request_email
@@ -109,11 +109,11 @@ class NotifyPreview < ActionMailer::Preview
end
def member_access_requested_email
- Notify.member_access_requested_email('group', user.id, user.id).message
+ Notify.member_access_requested_email(member.source_type, member.id, user.id).message
end
def member_invite_accepted_email
- Notify.member_invite_accepted_email('project', user.id).message
+ Notify.member_invite_accepted_email(member.source_type, member.id).message
end
def member_invite_declined_email