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: 14f0714082500f14b45c457f38c76d4c25125447 (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
29
30
31
32
33
34
# 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

      def key_from_fallback_message_id(mail_id)
        message_id_regexp = /\Areply\-(.+)@#{Gitlab.config.gitlab.host}\z/

        mail_id[message_id_regexp, 1]
      end
    end
  end
end