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: 'default',
    worker: 'EmailReceiverWorker'
  },
  service_desk_email: {
    queue: 'default',
    worker: 'ServiceDeskEmailReceiverWorker'
  }
}.freeze
DEFAULT_PATHS =

Default path strings (this is a data duplication with Settings which is not pulled in - see the service comment at the top of this file)

{
  shared_path: 'shared',
  encrypted_settings_path: 'encrypted_settings',
  incoming_email: {
    encrypted_secret_filename: 'incoming_email.yaml.enc'
  },
  service_desk_email: {
    encrypted_secret_filename: 'service_desk_email.yaml.enc'
  }
}.freeze

Class Method Summary collapse

Class Method Details

.enabled_configsObject



63
64
65
# File 'lib/gitlab/mail_room.rb', line 63

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

.enabled_mailbox_typesObject



67
68
69
# File 'lib/gitlab/mail_room.rb', line 67

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

.worker_for(mailbox_type) ⇒ Object



71
72
73
# File 'lib/gitlab/mail_room.rb', line 71

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