diff --git a/app/mailers/notify.rb b/app/mailers/notify.rb index ee738b4c580..c673eb3d161 100644 --- a/app/mailers/notify.rb +++ b/app/mailers/notify.rb @@ -4,7 +4,7 @@ class Notify < ActionMailer::Base default_url_options[:host] = Gitlab.config.web_host default_url_options[:protocol] = Gitlab.config.web_protocol - default_url_options[:port] = Gitlab.config.web_port + default_url_options[:port] = Gitlab.config.web_port if Gitlab.config.web_custom_port? default from: Gitlab.config.email_from diff --git a/config/initializers/1_settings.rb b/config/initializers/1_settings.rb index fb039e9e710..8b9ed8aebd6 100644 --- a/config/initializers/1_settings.rb +++ b/config/initializers/1_settings.rb @@ -20,17 +20,25 @@ class Settings < Settingslogic def web_port if web.https - nil + web['port'] = 443 else web['port'] ||= 80 - end + end.to_i + end + + def web_custom_port? + ![443, 80].include?(web_port) end def build_url raw_url = self.web_protocol raw_url << "://" raw_url << web_host - raw_url << ":#{web_port}" if web_port.to_i != 80 + + if web_custom_port? + raw_url << ":#{web_port}" + end + raw_url end