diff options
author | Dmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com> | 2015-04-15 12:37:51 +0000 |
---|---|---|
committer | Dmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com> | 2015-04-15 12:37:51 +0000 |
commit | d2a895dad80b5f7e12bb930fc92750d6848f7b21 (patch) | |
tree | 29e5a2baa51439254f16fa6c2c38c8b9235ca7b8 /app/mailers/notify.rb | |
parent | 089f5b914eed846c32a00f0fa71f7cfdca1dd654 (diff) | |
parent | c26b001ebcf43c3bdc18d1afcfbafa87b0b18366 (diff) | |
download | gitlab-ce-d2a895dad80b5f7e12bb930fc92750d6848f7b21.tar.gz |
Merge branch 'emailsonpush-replyto' into 'master'
Set EmailsOnPush reply-to address to committer email when enabled.
Addresses private issue https://dev.gitlab.org/gitlab/gitlabhq/issues/2227.
See merge request !520
Diffstat (limited to 'app/mailers/notify.rb')
-rw-r--r-- | app/mailers/notify.rb | 22 |
1 files changed, 13 insertions, 9 deletions
diff --git a/app/mailers/notify.rb b/app/mailers/notify.rb index 7c8b37029d1..2c0d451511f 100644 --- a/app/mailers/notify.rb +++ b/app/mailers/notify.rb @@ -60,20 +60,24 @@ class Notify < ActionMailer::Base address end + def can_send_from_user_email?(sender) + sender_domain = sender.email.split("@").last + self.class.allowed_email_domains.include?(sender_domain) + 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, send_from_user_email = false) - if sender = User.find(sender_id) - address = default_sender_address - address.display_name = sender.name + return unless sender = User.find(sender_id) + + address = default_sender_address + address.display_name = sender.name - sender_domain = sender.email.split("@").last - if send_from_user_email && self.class.allowed_email_domains.include?(sender_domain) - address.address = sender.email - end - - address.format + if send_from_user_email && can_send_from_user_email?(sender) + address.address = sender.email end + + address.format end # Look up a User by their ID and return their email address |