diff options
author | Pierre de La Morinerie <pierre@capitainetrain.com> | 2014-02-17 21:49:42 +0400 |
---|---|---|
committer | Pierre de La Morinerie <pierre@capitainetrain.com> | 2014-02-19 21:25:18 +0400 |
commit | 96dded3ec8401e9832b3888338f37c846bd43583 (patch) | |
tree | ae782ede2d7b2668c7cc659a1ebb03b086916502 /app/mailers/emails/issues.rb | |
parent | 57cb1ca7917f27f2c7500858fb66d53b3ea49783 (diff) |
Send emails from the author
This changes the email "From" field from "gitlab@example.com" to either:
* "John Doe <gitlab@example.com>" if the author of the action is known,
* "GitLab <gitlab@example.com>" otherwise.
Rationale: this allow mails to appear as if they were sent by the
author. It appears in the mailbox more like a real discussion between
the sender and the receiver ("John sent: we should refactor this") and
less like a robot notifying about something.
Diffstat (limited to 'app/mailers/emails/issues.rb')
-rw-r--r-- | app/mailers/emails/issues.rb | 14 |
1 files changed, 9 insertions, 5 deletions
diff --git a/app/mailers/emails/issues.rb b/app/mailers/emails/issues.rb index dece5112c9e..3adb47dc5b1 100644 --- a/app/mailers/emails/issues.rb +++ b/app/mailers/emails/issues.rb @@ -3,15 +3,17 @@ module Emails def new_issue_email(recipient_id, issue_id) @issue = Issue.find(issue_id) @project = @issue.project - mail(to: recipient(recipient_id), + mail(from: sender(@issue.author_id), + to: recipient(recipient_id), subject: subject("#{@issue.title} (##{@issue.iid})")) end - def reassigned_issue_email(recipient_id, issue_id, previous_assignee_id) + def reassigned_issue_email(recipient_id, issue_id, previous_assignee_id, updated_by_user_id) @issue = Issue.find(issue_id) @previous_assignee = User.find_by(id: previous_assignee_id) if previous_assignee_id @project = @issue.project - mail(to: recipient(recipient_id), + mail(from: sender(updated_by_user_id), + to: recipient(recipient_id), subject: subject("#{@issue.title} (##{@issue.iid})")) end @@ -19,7 +21,8 @@ module Emails @issue = Issue.find issue_id @project = @issue.project @updated_by = User.find updated_by_user_id - mail(to: recipient(recipient_id), + mail(from: sender(updated_by_user_id), + to: recipient(recipient_id), subject: subject("#{@issue.title} (##{@issue.iid})")) end @@ -28,7 +31,8 @@ module Emails @issue_status = status @project = @issue.project @updated_by = User.find updated_by_user_id - mail(to: recipient(recipient_id), + mail(from: sender(updated_by_user_id), + to: recipient(recipient_id), subject: subject("#{@issue.title} (##{@issue.iid})")) end end |