diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2022-01-20 12:16:11 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2022-01-20 12:16:11 +0300 |
commit | edaa33dee2ff2f7ea3fac488d41558eb5f86d68c (patch) | |
tree | 11f143effbfeba52329fb7afbd05e6e2a3790241 /lib/gitlab/mail_room.rb | |
parent | d8a5691316400a0f7ec4f83832698f1988eb27c1 (diff) |
Add latest changes from gitlab-org/gitlab@14-7-stable-eev14.7.0-rc42
Diffstat (limited to 'lib/gitlab/mail_room.rb')
-rw-r--r-- | lib/gitlab/mail_room.rb | 16 |
1 files changed, 12 insertions, 4 deletions
diff --git a/lib/gitlab/mail_room.rb b/lib/gitlab/mail_room.rb index 75d27ed8cc1..e93a297cee4 100644 --- a/lib/gitlab/mail_room.rb +++ b/lib/gitlab/mail_room.rb @@ -25,7 +25,7 @@ module Gitlab # Email specific configuration which is merged with configuration # fetched from YML config file. - ADDRESS_SPECIFIC_CONFIG = { + MAILBOX_SPECIFIC_CONFIGS = { incoming_email: { queue: 'email_receiver', worker: 'EmailReceiverWorker' @@ -38,7 +38,15 @@ module Gitlab class << self def enabled_configs - @enabled_configs ||= configs.select { |config| enabled?(config) } + @enabled_configs ||= configs.select { |_key, config| enabled?(config) } + end + + def enabled_mailbox_types + enabled_configs.keys.map(&:to_s) + end + + def worker_for(mailbox_type) + MAILBOX_SPECIFIC_CONFIGS.try(:[], mailbox_type.to_sym).try(:[], :worker).try(:safe_constantize) end private @@ -48,7 +56,7 @@ module Gitlab end def configs - ADDRESS_SPECIFIC_CONFIG.keys.map { |key| fetch_config(key) } + MAILBOX_SPECIFIC_CONFIGS.to_h { |key, _value| [key, fetch_config(key)] } end def fetch_config(config_key) @@ -63,7 +71,7 @@ module Gitlab def merged_configs(config_key) yml_config = load_yaml.fetch(config_key, {}) - specific_config = ADDRESS_SPECIFIC_CONFIG.fetch(config_key, {}) + specific_config = MAILBOX_SPECIFIC_CONFIGS.fetch(config_key, {}) DEFAULT_CONFIG.merge(specific_config, yml_config) do |_key, oldval, newval| newval.nil? ? oldval : newval end |