diff options
author | Pierre de La Morinerie <pierre@capitainetrain.com> | 2014-02-21 22:39:09 +0400 |
---|---|---|
committer | Pierre de La Morinerie <pierre@capitainetrain.com> | 2014-06-10 19:09:15 +0400 |
commit | 466b768bb34730ee6a24d950333c232009c34bbd (patch) | |
tree | 7ee2e0263b60e495c4c5013376d3564a92811f22 /app | |
parent | 772f2f1ac8aab40a2cd62f285af131eb61ad12bb (diff) |
Send notification emails to the "project", and put people in Cc
This fixes email threading in Mail.app, that doesn't like when a thread
doesn't have stable recipients.
For instance, here is a possible sender-recipient combinations before:
From: A
To: Me
New issue
From: B
To: Me
Reply on new issue
From: A
To: Me
Another reply
Mail.app doesn't see B as a participant to the original email thread,
and decides to break the thread: it will group all messages from A
together, and separately all messages from B.
This commit makes the thread look like this:
From: A
To: gitlab/project
Cc: Me
New issue
From: B
To: gitlab/project
Cc: Me
Reply on new issue
From: A
To: gitlab/project
Cc: Me
Another reply
Mail.app sees a common recipient, and group the thread correctly.
Diffstat (limited to 'app')
-rw-r--r-- | app/mailers/emails/groups.rb | 2 | ||||
-rw-r--r-- | app/mailers/emails/issues.rb | 8 | ||||
-rw-r--r-- | app/mailers/emails/merge_requests.rb | 8 | ||||
-rw-r--r-- | app/mailers/emails/notes.rb | 8 | ||||
-rw-r--r-- | app/mailers/emails/projects.rb | 6 | ||||
-rw-r--r-- | app/mailers/notify.rb | 14 |
6 files changed, 30 insertions, 16 deletions
diff --git a/app/mailers/emails/groups.rb b/app/mailers/emails/groups.rb index 1654fc55bca..39527b00e9f 100644 --- a/app/mailers/emails/groups.rb +++ b/app/mailers/emails/groups.rb @@ -4,7 +4,7 @@ module Emails @membership = UsersGroup.find(user_group_id) @group = @membership.group @target_url = group_url(@group) - mail(to: @membership.user.email, + mail(cc: @membership.user.email, subject: subject("Access to group was granted")) end end diff --git a/app/mailers/emails/issues.rb b/app/mailers/emails/issues.rb index a096df9dc0d..50676ac10cb 100644 --- a/app/mailers/emails/issues.rb +++ b/app/mailers/emails/issues.rb @@ -6,7 +6,7 @@ module Emails @target_url = project_issue_url(@project, @issue) set_message_id("issue_#{issue_id}") mail(from: sender(@issue.author_id), - to: recipient(recipient_id), + cc: recipient(recipient_id), subject: subject("#{@issue.title} (##{@issue.iid})")) end @@ -17,7 +17,7 @@ module Emails @target_url = project_issue_url(@project, @issue) set_reference("issue_#{issue_id}") mail(from: sender(updated_by_user_id), - to: recipient(recipient_id), + cc: recipient(recipient_id), subject: subject("#{@issue.title} (##{@issue.iid})")) end @@ -28,7 +28,7 @@ module Emails @target_url = project_issue_url(@project, @issue) set_reference("issue_#{issue_id}") mail(from: sender(updated_by_user_id), - to: recipient(recipient_id), + cc: recipient(recipient_id), subject: subject("#{@issue.title} (##{@issue.iid})")) end @@ -40,7 +40,7 @@ module Emails @target_url = project_issue_url(@project, @issue) set_reference("issue_#{issue_id}") mail(from: sender(updated_by_user_id), - to: recipient(recipient_id), + cc: recipient(recipient_id), subject: subject("#{@issue.title} (##{@issue.iid})")) end end diff --git a/app/mailers/emails/merge_requests.rb b/app/mailers/emails/merge_requests.rb index ea5671c4502..6b46cc90e08 100644 --- a/app/mailers/emails/merge_requests.rb +++ b/app/mailers/emails/merge_requests.rb @@ -6,7 +6,7 @@ module Emails @target_url = project_merge_request_url(@project, @merge_request) set_message_id("merge_request_#{merge_request_id}") mail(from: sender(@merge_request.author_id), - to: recipient(recipient_id), + cc: recipient(recipient_id), subject: subject("#{@merge_request.title} (##{@merge_request.iid})")) end @@ -17,7 +17,7 @@ module Emails @target_url = project_merge_request_url(@project, @merge_request) set_reference("merge_request_#{merge_request_id}") mail(from: sender(updated_by_user_id), - to: recipient(recipient_id), + cc: recipient(recipient_id), subject: subject("#{@merge_request.title} (##{@merge_request.iid})")) end @@ -28,7 +28,7 @@ module Emails @target_url = project_merge_request_url(@project, @merge_request) set_reference("merge_request_#{merge_request_id}") mail(from: sender(updated_by_user_id), - to: recipient(recipient_id), + cc: recipient(recipient_id), subject: subject("#{@merge_request.title} (##{@merge_request.iid})")) end @@ -38,7 +38,7 @@ module Emails @target_url = project_merge_request_url(@project, @merge_request) set_reference("merge_request_#{merge_request_id}") mail(from: sender(updated_by_user_id), - to: recipient(recipient_id), + cc: recipient(recipient_id), subject: subject("#{@merge_request.title} (##{@merge_request.iid})")) end end diff --git a/app/mailers/emails/notes.rb b/app/mailers/emails/notes.rb index 8d1f17b0f81..d6ab63fe68c 100644 --- a/app/mailers/emails/notes.rb +++ b/app/mailers/emails/notes.rb @@ -6,7 +6,7 @@ module Emails @project = @note.project @target_url = project_commit_url(@project, @commit, anchor: "note_#{@note.id}") mail(from: sender(@note.author_id), - to: recipient(recipient_id), + cc: recipient(recipient_id), subject: subject("#{@commit.title} (#{@commit.short_id})")) end @@ -17,7 +17,7 @@ module Emails @target_url = project_issue_url(@project, @issue, anchor: "note_#{@note.id}") set_reference("issue_#{@issue.id}") mail(from: sender(@note.author_id), - to: recipient(recipient_id), + cc: recipient(recipient_id), subject: subject("#{@issue.title} (##{@issue.iid})")) end @@ -28,7 +28,7 @@ module Emails @target_url = project_merge_request_url(@project, @merge_request, anchor: "note_#{@note.id}") set_reference("merge_request_#{@merge_request.id}") mail(from: sender(@note.author_id), - to: recipient(recipient_id), + cc: recipient(recipient_id), subject: subject("#{@merge_request.title} (##{@merge_request.iid})")) end @@ -37,7 +37,7 @@ module Emails @project = @note.project @target_url = project_wall_url(@note.project, anchor: "note_#{@note.id}") mail(from: sender(@note.author_id), - to: recipient(recipient_id), + cc: recipient(recipient_id), subject: subject("Note on wall")) end end diff --git a/app/mailers/emails/projects.rb b/app/mailers/emails/projects.rb index 9f99c11ea30..6017d9192ec 100644 --- a/app/mailers/emails/projects.rb +++ b/app/mailers/emails/projects.rb @@ -4,7 +4,7 @@ module Emails @users_project = UsersProject.find user_project_id @project = @users_project.project @target_url = project_url(@project) - mail(to: @users_project.user.email, + mail(cc: @users_project.user.email, subject: subject("Access to project was granted")) end @@ -12,7 +12,7 @@ module Emails @user = User.find user_id @project = Project.find project_id @target_url = project_url(@project) - mail(to: @user.email, + mail(cc: @user.email, subject: subject("Project was moved")) end @@ -30,7 +30,7 @@ module Emails end mail(from: sender(author_id), - to: recipient, + cc: recipient, subject: subject("New push to repository")) end end diff --git a/app/mailers/notify.rb b/app/mailers/notify.rb index 84a0da0129d..8eea8cf25e0 100644 --- a/app/mailers/notify.rb +++ b/app/mailers/notify.rb @@ -1,4 +1,6 @@ class Notify < ActionMailer::Base + include ActionDispatch::Routing::PolymorphicRoutes + include Emails::Issues include Emails::MergeRequests include Emails::Notes @@ -16,6 +18,7 @@ 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 @@ -32,6 +35,17 @@ 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) |