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 17:49:40 +0300
committerDouwe Maan <douwe@gitlab.com>2015-02-25 17:51:13 +0300
commit969de4c15a876ab9096f163ef6182571ca199492 (patch)
treef6e493aa98c5fa80fe6bb8e30102a1b84f7a77f6 /app/mailers
parent5d86332153838252384f9f87a0ae3e34c46eb266 (diff)
Fix EmailsOnPush to allow sending from @company.com for GitLab at gitlab.corp.company.com.
Diffstat (limited to 'app/mailers')
-rw-r--r--app/mailers/notify.rb17
1 files changed, 16 insertions, 1 deletions
diff --git a/app/mailers/notify.rb b/app/mailers/notify.rb
index 00d609cd93c..65925b61e94 100644
--- a/app/mailers/notify.rb
+++ b/app/mailers/notify.rb
@@ -34,6 +34,20 @@ class Notify < ActionMailer::Base
)
end
+ # Splits "gitlab.corp.company.com" up into "gitlab.corp.company.com",
+ # "corp.company.com" and "company.com".
+ # Respects set tld length so "company.co.uk" won't match "somethingelse.uk"
+ def self.allowed_email_domains
+ domain_parts = Gitlab.config.gitlab.host.split(".")
+ allowed_domains = []
+ begin
+ allowed_domains << domain_parts.join(".")
+ domain_parts.shift
+ end while domain_parts.length > ActionDispatch::Http::URL.tld_length
+
+ allowed_domains
+ end
+
private
# The default email address to send emails from
@@ -50,7 +64,8 @@ class Notify < ActionMailer::Base
address = default_sender_address
address.display_name = sender.name
- if send_from_user_email && sender.email.end_with?("@#{Gitlab.config.gitlab.host}")
+ sender_domain = sender.email.split("@").last
+ if send_from_user_email && self.class.allowed_email_domains.include?(sender_domain)
address.address = sender.email
end