Welcome to mirror list, hosted at ThFree Co, Russian Federation.

service_desk_email.rb « gitlab « lib - gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 52da10eff3e53cf4a29e33e59e4613f045e1a8c1 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
# 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

      def address_for_key(key)
        return if config.address.blank?

        config.address.sub(Gitlab::IncomingEmail::WILDCARD_PLACEHOLDER, key)
      end
    end
  end
end