Module: Gitlab::MailRoom

Defined in:
lib/gitlab/mail_room.rb,
lib/gitlab/mail_room/authenticator.rb

Defined Under Namespace

Classes: Authenticator

Constant Summary collapse

RAILS_ROOT_DIR =
Pathname.new('../..').expand_path(__dir__).freeze
DELIVERY_METHOD_SIDEKIQ =
'sidekiq'
DELIVERY_METHOD_WEBHOOK =
'webhook'
INTERNAL_API_REQUEST_HEADER =
'Gitlab-Mailroom-Api-Request'
INTERNAL_API_REQUEST_JWT_ISSUER =
'gitlab-mailroom'
DEFAULT_CONFIG =
{
  enabled: false,
  port: 143,
  ssl: false,
  start_tls: false,
  mailbox: 'inbox',
  idle_timeout: 60,
  log_path: RAILS_ROOT_DIR.join('log', 'mail_room_json.log'),
  expunge_deleted: false,
  delivery_method: DELIVERY_METHOD_SIDEKIQ
}.freeze
MAILBOX_SPECIFIC_CONFIGS =

Email specific configuration which is merged with configuration fetched from YML config file.

{
  incoming_email: {
    queue: 'email_receiver',
    worker: 'EmailReceiverWorker'
  },
  service_desk_email: {
    queue: 'service_desk_email_receiver',
    worker: 'ServiceDeskEmailReceiverWorker'
  }
}.freeze

Class Method Summary collapse

Class Method Details

.enabled_configsObject


46
47
48
# File 'lib/gitlab/mail_room.rb', line 46

def enabled_configs
  @enabled_configs ||= configs.select { |_key, config| enabled?(config) }
end

.enabled_mailbox_typesObject


50
51
52
# File 'lib/gitlab/mail_room.rb', line 50

def enabled_mailbox_types
  enabled_configs.keys.map(&:to_s)
end

.worker_for(mailbox_type) ⇒ Object


54
55
56
# File 'lib/gitlab/mail_room.rb', line 54

def worker_for(mailbox_type)
  MAILBOX_SPECIFIC_CONFIGS.try(:[], mailbox_type.to_sym).try(:[], :worker).try(:safe_constantize)
end