diff options
Diffstat (limited to 'app/mailers/notify.rb')
-rw-r--r-- | app/mailers/notify.rb | 66 |
1 files changed, 8 insertions, 58 deletions
diff --git a/app/mailers/notify.rb b/app/mailers/notify.rb index d65bead9cfe..84a0da0129d 100644 --- a/app/mailers/notify.rb +++ b/app/mailers/notify.rb @@ -1,6 +1,4 @@ class Notify < ActionMailer::Base - include ActionDispatch::Routing::PolymorphicRoutes - include Emails::Issues include Emails::MergeRequests include Emails::Notes @@ -18,7 +16,6 @@ class Notify < ActionMailer::Base default_url_options[:script_name] = Gitlab.config.gitlab.relative_url_root default from: Proc.new { default_sender_address.format } - default to: Proc.new { project_sender_address.format } default reply_to: "noreply@#{Gitlab.config.gitlab.host}" # Just send email with 2 seconds delay @@ -35,17 +32,6 @@ class Notify < ActionMailer::Base address end - # The default email address to send emails to. Includes the project name if possible. - def project_sender_address - if @project - address = default_sender_address - address.display_name = @project.name_with_namespace - address - else - default_sender_address - end - end - # Return an email address that displays the name of the sender. # Only the displayed name changes; the actual email address is always the same. def sender(sender_id) @@ -67,6 +53,14 @@ class Notify < ActionMailer::Base end end + # Set the Message-ID header field + # + # local_part - The local part of the message ID + # + def set_message_id(local_part) + headers["Message-ID"] = "<#{local_part}@#{Gitlab.config.gitlab.host}>" + end + # Set the References header field # # local_part - The local part of the referenced message ID @@ -99,48 +93,4 @@ class Notify < ActionMailer::Base subject << extra.join(' | ') if extra.present? subject end - - # Return a string suitable for inclusion in the 'Message-Id' mail header. - # - # The message-id is generated from the unique URL to a model object. - def message_id(model) - model_name = model.class.model_name.singular_route_key - "<#{model_name}_#{model.id}@#{Gitlab.config.gitlab.host}>" - end - - # Send an email that starts a new conversation thread, - # with headers suitable for grouping by thread in email clients. - # - # See: mail_answer_thread - def mail_new_thread(model, headers = {}, &block) - raise ArgumentError, '"To:" header will be overwritten; use "Cc:" or "Bcc:"' unless headers[:to].nil? - headers[:to] = project_sender_address.format - - headers['Message-ID'] = message_id(model) - - mail(headers, &block) - end - - # Send an email that responds to an existing conversation thread, - # with headers suitable for grouping by thread in email clients. - # - # For grouping emails by thread, email clients heuristics require the answers to: - # - # * have a subject that begin by 'Re: ' - # * have a 'In-Reply-To' or 'References' header that references the original 'Message-ID' - # * have stable 'From' and 'To' headers between messages of the same thread - # - def mail_answer_thread(model, headers = {}, &block) - raise ArgumentError, '"To:" header will be overwritten; use "Cc:" or "Bcc:"' unless headers[:to].nil? - headers[:to] = project_sender_address.format - - headers['In-Reply-To'] = message_id(model) - headers['References'] = message_id(model) - - if (headers[:subject]) - headers[:subject].prepend('Re: ') - end - - mail(headers, &block) - end end |