summaryrefslogtreecommitdiff
path: root/config/mail_room.yml
diff options
context:
space:
mode:
authorDouwe Maan <douwe@selenight.nl>2016-02-26 18:48:13 -0800
committerDouwe Maan <douwe@selenight.nl>2016-02-26 18:48:13 -0800
commitbbdb9ba0361496d04d211c2a6f75c94e7df9d8f7 (patch)
treef09cb28100f066de404a63e3988f6cab49bb5ec7 /config/mail_room.yml
parent01160fc06182de89c400af174861f6545ad6ceb8 (diff)
downloadgitlab-ce-bbdb9ba0361496d04d211c2a6f75c94e7df9d8f7.tar.gz
Don't load all of GitLab in mail_room
Fixes #12731
Diffstat (limited to 'config/mail_room.yml')
-rw-r--r--config/mail_room.yml85
1 files changed, 49 insertions, 36 deletions
diff --git a/config/mail_room.yml b/config/mail_room.yml
index 42f6f74c465..f266a70ee0d 100644
--- a/config/mail_room.yml
+++ b/config/mail_room.yml
@@ -1,39 +1,52 @@
:mailboxes:
<%
-require_relative 'config/environment.rb'
-
-if Gitlab::IncomingEmail.enabled?
- config = Gitlab::IncomingEmail.config
-
- redis_config_file = "config/resque.yml"
- redis_url =
- if File.exists?(redis_config_file)
- YAML.load_file(redis_config_file)[Rails.env]
- else
- "redis://localhost:6379"
- end
- %>
- -
- :host: <%= config.host.to_json %>
- :port: <%= config.port.to_json %>
- :ssl: <%= config.ssl.to_json %>
- :start_tls: <%= config.start_tls.to_json %>
- :email: <%= config.user.to_json %>
- :password: <%= config.password.to_json %>
-
- :name: <%= config.mailbox.to_json %>
-
- :delete_after_delivery: true
-
- :delivery_method: sidekiq
- :delivery_options:
- :redis_url: <%= redis_url.to_json %>
- :namespace: resque:gitlab
- :queue: incoming_email
- :worker: EmailReceiverWorker
-
- :arbitration_method: redis
- :arbitration_options:
- :redis_url: <%= redis_url.to_json %>
- :namespace: mail_room:gitlab
+require "yaml"
+require "json"
+
+rails_env = ENV["RAILS_ENV"] || ENV["RACK_ENV"] || "development"
+
+config_file = ENV["MAIL_ROOM_GITLAB_CONFIG_FILE"] || "config/gitlab.yml"
+if File.exists?(config_file)
+ all_config = YAML.load_file(config_file)[rails_env]
+
+ config = all_config["incoming_email"] || {}
+ config['enabled'] = false if config['enabled'].nil?
+ config['port'] = 143 if config['port'].nil?
+ config['ssl'] = false if config['ssl'].nil?
+ config['start_tls'] = false if config['start_tls'].nil?
+ config['mailbox'] = "inbox" if config['mailbox'].nil?
+
+ if config['enabled'] && config['address'] && config['address'].include?('%{key}')
+ redis_config_file = "config/resque.yml"
+ redis_url =
+ if File.exists?(redis_config_file)
+ YAML.load_file(redis_config_file)[rails_env]
+ else
+ "redis://localhost:6379"
+ end
+ %>
+ -
+ :host: <%= config['host'].to_json %>
+ :port: <%= config['port'].to_json %>
+ :ssl: <%= config['ssl'].to_json %>
+ :start_tls: <%= config['start_tls'].to_json %>
+ :email: <%= config['user'].to_json %>
+ :password: <%= config['password'].to_json %>
+
+ :name: <%= config['mailbox'].to_json %>
+
+ :delete_after_delivery: true
+
+ :delivery_method: sidekiq
+ :delivery_options:
+ :redis_url: <%= redis_url.to_json %>
+ :namespace: resque:gitlab
+ :queue: incoming_email
+ :worker: EmailReceiverWorker
+
+ :arbitration_method: redis
+ :arbitration_options:
+ :redis_url: <%= redis_url.to_json %>
+ :namespace: mail_room:gitlab
+ <% end %>
<% end %>