Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'app/mailers/emails/service_desk.rb')
-rw-r--r--app/mailers/emails/service_desk.rb38
1 files changed, 33 insertions, 5 deletions
diff --git a/app/mailers/emails/service_desk.rb b/app/mailers/emails/service_desk.rb
index 2953ec6cbe5..1295f978049 100644
--- a/app/mailers/emails/service_desk.rb
+++ b/app/mailers/emails/service_desk.rb
@@ -17,24 +17,30 @@ module Emails
email_sender = sender(
@support_bot.id,
send_from_user_email: false,
- sender_name: @project.service_desk_setting&.outgoing_name
+ sender_name: @service_desk_setting&.outgoing_name,
+ sender_email: service_desk_sender_email_address
)
options = service_desk_options(email_sender, 'thank_you', @issue.external_author)
.merge(subject: "Re: #{subject_base}")
- mail_new_thread(@issue, options)
+ inject_service_desk_custom_email(mail_new_thread(@issue, options))
end
def service_desk_new_note_email(issue_id, note_id, recipient)
@note = Note.find(note_id)
setup_service_desk_mail(issue_id)
- email_sender = sender(@note.author_id)
+ email_sender = sender(
+ @note.author_id,
+ send_from_user_email: false,
+ sender_email: service_desk_sender_email_address
+ )
+
add_uploads_as_attachments if Feature.enabled?(:service_desk_new_note_email_native_attachments, @note.project)
options = service_desk_options(email_sender, 'new_note', recipient)
.merge(subject: subject_base)
- mail_answer_thread(@issue, options)
+ inject_service_desk_custom_email(mail_answer_thread(@issue, options))
end
private
@@ -44,6 +50,8 @@ module Emails
@project = @issue.project
@support_bot = User.support_bot
+ @service_desk_setting = @project.service_desk_setting
+
@sent_notification = SentNotification.record(@issue, @support_bot.id, reply_key)
end
@@ -55,10 +63,26 @@ module Emails
next unless template_body = template_content(email_type)
options[:body] = template_body
- options[:content_type] = 'text/html'
+ options[:content_type] = 'text/html' unless attachments.present?
end
end
+ def inject_service_desk_custom_email(mail)
+ return mail unless service_desk_custom_email_enabled?
+
+ mail.delivery_method(::Mail::SMTP, @service_desk_setting.custom_email_delivery_options)
+ end
+
+ def service_desk_custom_email_enabled?
+ Feature.enabled?(:service_desk_custom_email, @project) && @service_desk_setting&.custom_email_enabled?
+ end
+
+ def service_desk_sender_email_address
+ return unless service_desk_custom_email_enabled?
+
+ @service_desk_setting.custom_email
+ end
+
def template_content(email_type)
template = Gitlab::Template::ServiceDeskTemplate.find(email_type, @project)
text = substitute_template_replacements(template.content)
@@ -77,6 +101,10 @@ module Emails
.gsub(/%\{\s*ISSUE_ID\s*\}/, issue_id)
.gsub(/%\{\s*ISSUE_PATH\s*\}/, issue_path)
.gsub(/%\{\s*NOTE_TEXT\s*\}/, note_text)
+ .gsub(/%\{\s*SYSTEM_HEADER\s*\}/, text_header_message.to_s)
+ .gsub(/%\{\s*SYSTEM_FOOTER\s*\}/, text_footer_message.to_s)
+ .gsub(/%\{\s*UNSUBSCRIBE_URL\s*\}/, unsubscribe_sent_notification_url(@sent_notification))
+ .gsub(/%\{\s*ADDITIONAL_TEXT\s*\}/, service_desk_email_additional_text.to_s)
end
def issue_id