debian-mirror-gitlab/lib/gitlab/incoming_email.rb

35 lines
745 B
Ruby
Raw Normal View History

2018-12-13 13:39:08 +05:30
# frozen_string_literal: true
2015-09-25 12:07:36 +05:30
module Gitlab
module IncomingEmail
2017-08-17 22:00:37 +05:30
class << self
2023-01-13 00:05:48 +05:30
include Gitlab::Email::Common
2015-09-25 12:07:36 +05:30
2023-01-13 00:05:48 +05:30
def config
incoming_email_config
2015-09-25 12:07:36 +05:30
end
2020-04-08 14:13:33 +05:30
def key_from_address(address, wildcard_address: nil)
wildcard_address ||= config.address
regex = address_regex(wildcard_address)
2015-09-25 12:07:36 +05:30
return unless regex
match = address.match(regex)
return unless match
match[1]
end
2015-10-24 18:46:33 +05:30
private
2020-04-08 14:13:33 +05:30
def address_regex(wildcard_address)
2019-07-07 11:18:12 +05:30
return unless wildcard_address
2015-09-25 12:07:36 +05:30
regex = Regexp.escape(wildcard_address)
2017-08-17 22:00:37 +05:30
regex = regex.sub(Regexp.escape(WILDCARD_PLACEHOLDER), '(.+)')
2020-03-13 15:44:24 +05:30
Regexp.new(/\A<?#{regex}>?\z/).freeze
2015-09-25 12:07:36 +05:30
end
end
end
end