Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDouwe Maan <douwe@gitlab.com>2015-02-25 16:05:45 +0300
committerDouwe Maan <douwe@gitlab.com>2015-02-25 16:20:35 +0300
commite0c186c35735a2dc9e05e88ad9975ae016c815d9 (patch)
treec040a133925106da34de651cb88e155988a079fc /app/mailers
parent0e7d1fd44f057c83c5384618f4599271f9fdd006 (diff)
Add option to send EmailsOnPush from committer email if domain matches.
See #1809.
Diffstat (limited to 'app/mailers')
-rw-r--r--app/mailers/emails/projects.rb6
-rw-r--r--app/mailers/notify.rb7
2 files changed, 9 insertions, 4 deletions
diff --git a/app/mailers/emails/projects.rb b/app/mailers/emails/projects.rb
index f3a2ae14d35..3b60aed6f9e 100644
--- a/app/mailers/emails/projects.rb
+++ b/app/mailers/emails/projects.rb
@@ -16,13 +16,13 @@ module Emails
subject: subject("Project was moved"))
end
- def repository_push_email(project_id, recipient, author_id, branch, compare)
+ def repository_push_email(project_id, recipient, author_id, branch, compare, send_from_committer_email = false)
@project = Project.find(project_id)
@author = User.find(author_id)
@compare = compare
@commits = Commit.decorate(compare.commits)
@diffs = compare.diffs
- @branch = branch
+ @branch = branch.gsub("refs/heads/", "")
@subject = "[#{@project.path_with_namespace}][#{@branch}] "
@@ -40,7 +40,7 @@ module Emails
@disable_footer = true
- mail(from: sender(author_id),
+ mail(from: sender(author_id, send_from_committer_email),
to: recipient,
subject: @subject)
end
diff --git a/app/mailers/notify.rb b/app/mailers/notify.rb
index 46ead62f75f..00d609cd93c 100644
--- a/app/mailers/notify.rb
+++ b/app/mailers/notify.rb
@@ -45,10 +45,15 @@ class Notify < ActionMailer::Base
# 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)
+ def sender(sender_id, send_from_user_email = false)
if sender = User.find(sender_id)
address = default_sender_address
address.display_name = sender.name
+
+ if send_from_user_email && sender.email.end_with?("@#{Gitlab.config.gitlab.host}")
+ address.address = sender.email
+ end
+
address.format
end
end