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

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

37 lines
812 B
Ruby
Raw Normal View History

2023-06-20 00:43:36 +05:30
# frozen_string_literal: true
module Gitlab
module Email
module IncomingEmail
class << self
include Gitlab::Email::Common
def config
incoming_email_config
end
def key_from_address(address, wildcard_address: nil)
wildcard_address ||= config.address
regex = address_regex(wildcard_address)
return unless regex
match = address.match(regex)
return unless match
match[1]
end
private
def address_regex(wildcard_address)
return unless wildcard_address
regex = Regexp.escape(wildcard_address)
regex = regex.sub(Regexp.escape(WILDCARD_PLACEHOLDER), '(.+)')
Regexp.new(/\A<?#{regex}>?\z/).freeze
end
end
end
end
end