Module: Gitlab::IncomingEmail

Defined in:
lib/gitlab/incoming_email.rb

Constant Summary collapse

FALLBACK_REPLY_MESSAGE_ID_REGEX =
/\Areply\-(.+)@#{Gitlab.config.gitlab.host}\Z/.freeze

Class Method Summary collapse

Class Method Details

.configObject


31
32
33
# File 'lib/gitlab/incoming_email.rb', line 31

def config
  Gitlab.config.incoming_email
end

.enabled?Boolean

Returns:

  • (Boolean)

6
7
8
# File 'lib/gitlab/incoming_email.rb', line 6

def enabled?
  config.enabled && config.address
end

.key_from_address(address) ⇒ Object


14
15
16
17
18
19
20
21
22
# File 'lib/gitlab/incoming_email.rb', line 14

def key_from_address(address)
  regex = address_regex
  return unless regex

  match = address.match(regex)
  return unless match

  match[1]
end

.key_from_fallback_reply_message_id(message_id) ⇒ Object


24
25
26
27
28
29
# File 'lib/gitlab/incoming_email.rb', line 24

def key_from_fallback_reply_message_id(message_id)
  match = message_id.match(FALLBACK_REPLY_MESSAGE_ID_REGEX)
  return unless match

  match[1]
end

.reply_address(key) ⇒ Object


10
11
12
# File 'lib/gitlab/incoming_email.rb', line 10

def reply_address(key)
  config.address.gsub('%{key}', key)
end