Commit a6c7d805 authored by Eric Eastwood's avatar Eric Eastwood

Add custom additonal email text to all emails

Fix https://gitlab.com/gitlab-org/gitlab-ee/issues/4474

Conflicts:
	db/schema.rb
	ee/app/controllers/ee/admin/application_settings_controller.rb
	ee/app/helpers/ee/application_settings_helper.rb
	ee/app/models/ee/application_setting.rb
	ee/app/models/license.rb
	ee/app/views/layouts/service_desk.html.haml
	ee/app/views/notify/approved_merge_request_email.html.haml
	ee/app/views/notify/service_desk_new_note_email.text.erb
	ee/app/views/notify/service_desk_thank_you_email.text.erb
	ee/app/views/notify/unapproved_merge_request_email.html.haml
	ee/lib/ee/api/entities.rb
	ee/spec/controllers/admin/application_settings_controller_spec.rb
	ee/spec/models/application_setting_spec.rb
	ee/spec/requests/api/settings_spec.rb
	lib/api/settings.rb
	spec/mailers/previews/notify_preview.rb
parent 1be9f587
Unfortunately, your email message to GitLab could not be processed. Unfortunately, your email message to GitLab could not be processed.
\
= @reason = @reason
...@@ -85,7 +85,6 @@ created in snippets, wikis, and repos. ...@@ -85,7 +85,6 @@ created in snippets, wikis, and repos.
- [Postfix for incoming email](reply_by_email_postfix_setup.md): Set up a - [Postfix for incoming email](reply_by_email_postfix_setup.md): Set up a
basic Postfix mail server with IMAP authentication on Ubuntu for incoming basic Postfix mail server with IMAP authentication on Ubuntu for incoming
emails. emails.
server with IMAP authentication on Ubuntu, to be used with Reply by email.
- [User Cohorts](../user/admin_area/user_cohorts.md): Display the monthly cohorts of new users and their activities over time. - [User Cohorts](../user/admin_area/user_cohorts.md): Display the monthly cohorts of new users and their activities over time.
[reply by email]: reply_by_email.md [reply by email]: reply_by_email.md
......
# Email
## Custom logo
The logo in the header of some emails can be customized, see the [logo customization section](../../../customization/branded_page_and_email_header.md).
...@@ -95,13 +95,13 @@ module Gitlab ...@@ -95,13 +95,13 @@ module Gitlab
args = [ref, oldrev, newrev] args = [ref, oldrev, newrev]
stdout, stderr, status = Open3.capture3(env, path, *args, options) stdout, stderr, status = Open3.capture3(env, path, *args, options)
[status.success?, (stderr.presence || stdout).gsub(/\R/, "<br>").html_safe] [status.success?, Gitlab::Utils.nlbr(stderr.presence || stdout)]
end end
def retrieve_error_message(stderr, stdout) def retrieve_error_message(stderr, stdout)
err_message = stderr.read err_message = stderr.read
err_message = err_message.blank? ? stdout.read : err_message err_message = err_message.blank? ? stdout.read : err_message
err_message.gsub(/\R/, "<br>").html_safe Gitlab::Utils.nlbr(err_message)
end end
end end
end end
......
...@@ -27,6 +27,11 @@ module Gitlab ...@@ -27,6 +27,11 @@ module Gitlab
.gsub(/(\A-+|-+\z)/, '') .gsub(/(\A-+|-+\z)/, '')
end end
# Converts newlines into HTML line break elements
def nlbr(str)
ActionView::Base.full_sanitizer.sanitize(str, tags: []).gsub(/\r?\n/, '<br>').html_safe
end
def remove_line_breaks(str) def remove_line_breaks(str)
str.gsub(/\r?\n/, '') str.gsub(/\r?\n/, '')
end end
......
class EmailRejectionMailerPreview < ActionMailer::Preview
def rejection
EmailRejectionMailer.rejection("some rejection reason", "From: someone@example.com\nraw email here").message
end
end
...@@ -58,16 +58,89 @@ class NotifyPreview < ActionMailer::Preview ...@@ -58,16 +58,89 @@ class NotifyPreview < ActionMailer::Preview
end end
end end
def closed_issue_email
Notify.closed_issue_email(user.id, issue.id, user.id).message
end
def issue_status_changed_email
Notify.issue_status_changed_email(user.id, issue.id, 'closed', user.id).message
end
def closed_merge_request_email
Notify.closed_merge_request_email(user.id, issue.id, user.id).message
end
def merge_request_status_email
Notify.merge_request_status_email(user.id, merge_request.id, 'closed', user.id).message
end
def merged_merge_request_email
Notify.merged_merge_request_email(user.id, merge_request.id, user.id).message
end
def member_access_denied_email
Notify.member_access_denied_email('project', project.id, user.id).message
end
def member_access_granted_email
Notify.member_access_granted_email('project', user.id).message
end
def member_access_requested_email
Notify.member_access_requested_email('group', user.id, 'some@example.com').message
end
def member_invite_accepted_email
Notify.member_invite_accepted_email('project', user.id).message
end
def member_invite_declined_email
Notify.member_invite_declined_email(
'project',
project.id,
'invite@example.com',
user.id
).message
end
def member_invited_email
Notify.member_invited_email('project', user.id, '1234').message
end
def pages_domain_enabled_email
cleanup do
pages_domain = PagesDomain.new(domain: 'my.example.com', project: project, verified_at: Time.now, enabled_until: 1.week.from_now)
Notify.pages_domain_enabled_email(pages_domain, user).message
end
end
def pipeline_success_email
Notify.pipeline_success_email(pipeline, pipeline.user.try(:email))
end
def pipeline_failed_email
Notify.pipeline_failed_email(pipeline, pipeline.user.try(:email))
end
private private
def project def project
@project ||= Project.find_by_full_path('gitlab-org/gitlab-test') @project ||= Project.find_by_full_path('gitlab-org/gitlab-test')
end end
def issue
@merge_request ||= project.issues.first
end
def merge_request def merge_request
@merge_request ||= project.merge_requests.first @merge_request ||= project.merge_requests.first
end end
def pipeline
@pipeline = Ci::Pipeline.last
end
def user def user
@user ||= User.last @user ||= User.last
end end
...@@ -94,14 +167,4 @@ class NotifyPreview < ActionMailer::Preview ...@@ -94,14 +167,4 @@ class NotifyPreview < ActionMailer::Preview
email email
end end
def pipeline_success_email
pipeline = Ci::Pipeline.last
Notify.pipeline_success_email(pipeline, pipeline.user.try(:email))
end
def pipeline_failed_email
pipeline = Ci::Pipeline.last
Notify.pipeline_failed_email(pipeline, pipeline.user.try(:email))
end
end end
class RepositoryCheckMailerPreview < ActionMailer::Preview
def notify
RepositoryCheckMailer.notify(3).message
end
end
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