Commit dda326f1 authored by Sean McGivern's avatar Sean McGivern

Merge branch 'ce-4474-custom-additional-text-in-confirmation-email' into 'master'

Add custom additional text to emails -- CE backport

Closes gitlab-ee#4474

See merge request gitlab-org/gitlab-ce!18183
parents 942488b8 a6c7d805
Unfortunately, your email message to GitLab could not be processed.
\
= @reason
......@@ -85,7 +85,6 @@ created in snippets, wikis, and repos.
- [Postfix for incoming email](reply_by_email_postfix_setup.md): Set up a
basic Postfix mail server with IMAP authentication on Ubuntu for incoming
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.
[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
args = [ref, oldrev, newrev]
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
def retrieve_error_message(stderr, stdout)
err_message = stderr.read
err_message = err_message.blank? ? stdout.read : err_message
err_message.gsub(/\R/, "<br>").html_safe
Gitlab::Utils.nlbr(err_message)
end
end
end
......
......@@ -27,6 +27,11 @@ module Gitlab
.gsub(/(\A-+|-+\z)/, '')
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)
str.gsub(/\r?\n/, '')
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
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
def project
@project ||= Project.find_by_full_path('gitlab-org/gitlab-test')
end
def issue
@merge_request ||= project.issues.first
end
def merge_request
@merge_request ||= project.merge_requests.first
end
def pipeline
@pipeline = Ci::Pipeline.last
end
def user
@user ||= User.last
end
......@@ -94,14 +167,4 @@ class NotifyPreview < ActionMailer::Preview
email
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
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