Commit c50004a26385d2d3f60584a3771b65355acd6ab5

Authored by Rhett Sutphin
1 parent 6ce9ef1b
Exists in master and in 1 other branch production

Allow errbit's own port to be configured.

This allows errbit to generate correct links in notifications when errbit is
served over a non-standard port.
app/models/issue_tracker.rb
@@ -4,6 +4,7 @@ class IssueTracker @@ -4,6 +4,7 @@ class IssueTracker
4 include HashHelper 4 include HashHelper
5 include Rails.application.routes.url_helpers 5 include Rails.application.routes.url_helpers
6 default_url_options[:host] = ActionMailer::Base.default_url_options[:host] 6 default_url_options[:host] = ActionMailer::Base.default_url_options[:host]
  7 + default_url_options[:port] = ActionMailer::Base.default_url_options[:port]
7 8
8 embedded_in :app, :inverse_of => :issue_tracker 9 embedded_in :app, :inverse_of => :issue_tracker
9 10
app/models/notification_service.rb
@@ -3,6 +3,7 @@ class NotificationService @@ -3,6 +3,7 @@ class NotificationService
3 3
4 include Rails.application.routes.url_helpers 4 include Rails.application.routes.url_helpers
5 default_url_options[:host] = ActionMailer::Base.default_url_options[:host] 5 default_url_options[:host] = ActionMailer::Base.default_url_options[:host]
  6 + default_url_options[:port] = ActionMailer::Base.default_url_options[:port]
6 7
7 field :room_id, :type => String 8 field :room_id, :type => String
8 field :user_id, :type => String 9 field :user_id, :type => String
config/config.example.yml
@@ -11,6 +11,10 @@ @@ -11,6 +11,10 @@
11 # The host of your errbit server 11 # The host of your errbit server
12 host: errbit.example.com 12 host: errbit.example.com
13 13
  14 +# The port for your errbit server.
  15 +# Only set this if it isn't the default for the protocol (i.e.. 80 for HTTP, 443 for HTTPS)
  16 +# port: 8080
  17 +
14 # Enforce SSL connections 18 # Enforce SSL connections
15 enforce_ssl: false 19 enforce_ssl: false
16 20
config/initializers/_load_config.rb
@@ -9,6 +9,7 @@ unless defined?(Errbit::Config) @@ -9,6 +9,7 @@ unless defined?(Errbit::Config)
9 # If Errbit is running on Heroku, config can be set from environment variables. 9 # If Errbit is running on Heroku, config can be set from environment variables.
10 if use_env 10 if use_env
11 Errbit::Config.host = ENV['ERRBIT_HOST'] 11 Errbit::Config.host = ENV['ERRBIT_HOST']
  12 + Errbit::Config.port = ENV['ERRBIT_PORT']
12 Errbit::Config.email_from = ENV['ERRBIT_EMAIL_FROM'] 13 Errbit::Config.email_from = ENV['ERRBIT_EMAIL_FROM']
13 # Not really easy to use like an env because need an array and ENV return a string :( 14 # Not really easy to use like an env because need an array and ENV return a string :(
14 # Errbit::Config.email_at_notices = ENV['ERRBIT_EMAIL_AT_NOTICES'] 15 # Errbit::Config.email_at_notices = ENV['ERRBIT_EMAIL_AT_NOTICES']
@@ -78,7 +79,12 @@ end @@ -78,7 +79,12 @@ end
78 79
79 # Set config specific values 80 # Set config specific values
80 (ActionMailer::Base.default_url_options ||= {}).tap do |default| 81 (ActionMailer::Base.default_url_options ||= {}).tap do |default|
81 - default.merge! :host => Errbit::Config.host if default[:host].blank? 82 + options_from_config = {
  83 + host: Errbit::Config.host,
  84 + port: Errbit::Config.port
  85 + }.select { |k, v| v }
  86 +
  87 + default.reverse_merge!(options_from_config)
82 end 88 end
83 89
84 if Rails.env.production? 90 if Rails.env.production?