2020-07-09 05:09:27 -04:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
|
|
|
module Gitlab
|
|
|
|
module ServiceDeskEmail
|
|
|
|
class << self
|
|
|
|
def enabled?
|
|
|
|
!!config&.enabled && config&.address.present?
|
|
|
|
end
|
|
|
|
|
|
|
|
def key_from_address(address)
|
|
|
|
wildcard_address = config&.address
|
|
|
|
return unless wildcard_address
|
|
|
|
|
|
|
|
Gitlab::IncomingEmail.key_from_address(address, wildcard_address: wildcard_address)
|
|
|
|
end
|
|
|
|
|
|
|
|
def config
|
|
|
|
Gitlab.config.service_desk_email
|
|
|
|
end
|
2020-08-12 17:09:54 -04:00
|
|
|
|
|
|
|
def address_for_key(key)
|
|
|
|
return if config.address.blank?
|
|
|
|
|
|
|
|
config.address.sub(Gitlab::IncomingEmail::WILDCARD_PLACEHOLDER, key)
|
|
|
|
end
|
2020-07-09 05:09:27 -04:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|