Commit 33709d43 authored by Rémy Coutable's avatar Rémy Coutable

Minimize CE/EE diff in Notify

Signed-off-by: default avatarRémy Coutable <remy@rymai.me>
parent cb8118df
class Notify < BaseMailer
prepend EE::Notify
prepend ::EE::Notify
include ActionDispatch::Routing::PolymorphicRoutes
include GitlabRoutingHelper
include Emails::AdminNotification
include Emails::Issues
include Emails::CsvExport
include Emails::MergeRequests
include Emails::Notes
include Emails::PagesDomains
......@@ -15,8 +13,6 @@ class Notify < BaseMailer
include Emails::Pipelines
include Emails::Members
include Emails::EE::ServiceDesk
helper MergeRequestsHelper
helper DiffHelper
helper BlobHelper
......
......@@ -4,6 +4,10 @@ module EE
extend ::Gitlab::Utils::Override
included do
include ::Emails::AdminNotification
include ::Emails::CsvExport
include ::Emails::ServiceDesk
attr_reader :group
end
......
module Emails
module EE
module ServiceDesk
extend ActiveSupport::Concern
included do
layout 'service_desk', only: [:service_desk_thank_you_email, :service_desk_new_note_email]
end
def service_desk_thank_you_email(issue_id)
setup_service_desk_mail(issue_id)
mail_new_thread(@issue, service_desk_options(@support_bot.id))
end
def service_desk_new_note_email(issue_id, note_id)
@note = Note.find(note_id)
setup_service_desk_mail(issue_id)
mail_answer_thread(@issue, service_desk_options(@note.author_id))
end
private
def setup_service_desk_mail(issue_id)
@issue = Issue.find(issue_id)
@project = @issue.project
@support_bot = User.support_bot
@sent_notification = SentNotification.record(@issue, @support_bot.id, reply_key)
end
def service_desk_options(author_id)
{
from: sender(author_id),
to: @issue.service_desk_reply_to,
subject: "Re: #{@issue.title} (##{@issue.iid})"
}
end
end
end
end
module Emails
module ServiceDesk
extend ActiveSupport::Concern
included do
layout 'service_desk', only: [:service_desk_thank_you_email, :service_desk_new_note_email]
end
def service_desk_thank_you_email(issue_id)
setup_service_desk_mail(issue_id)
mail_new_thread(@issue, service_desk_options(@support_bot.id))
end
def service_desk_new_note_email(issue_id, note_id)
@note = Note.find(note_id)
setup_service_desk_mail(issue_id)
mail_answer_thread(@issue, service_desk_options(@note.author_id))
end
private
def setup_service_desk_mail(issue_id)
@issue = Issue.find(issue_id)
@project = @issue.project
@support_bot = User.support_bot
@sent_notification = SentNotification.record(@issue, @support_bot.id, reply_key)
end
def service_desk_options(author_id)
{
from: sender(author_id),
to: @issue.service_desk_reply_to,
subject: "Re: #{@issue.title} (##{@issue.iid})"
}
end
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