Module: Gitlab::Email::ServiceDesk::CustomEmail
- Defined in:
- lib/gitlab/email/service_desk/custom_email.rb
Overview
Doesn’t include Gitlab::Email::Common because a custom email doesn’t support all features and methods of ingestable email addresses like incoming_email and service_desk_email.
Constant Summary collapse
- REPLY_ADDRESS_KEY_REGEXP =
/\+([0-9a-f]{32})@/
- EMAIL_REGEXP_WITH_ANCHORS =
/\A(?>[a-zA-Z0-9]+|[\-._]+){1,255}@[\w\-.]{1,255}\.{1}[a-zA-Z]{2,63}\z/
Class Method Summary collapse
- .key_from_reply_address(email) ⇒ Object
-
.key_from_settings(email) ⇒ Object
Checks whether the given email is a custom email and returns the project’s mail key.
- .reply_address(issue, reply_key) ⇒ Object
Class Method Details
.key_from_reply_address(email) ⇒ Object
25 26 27 28 29 30 31 32 33 34 35 36 37 |
# File 'lib/gitlab/email/service_desk/custom_email.rb', line 25 def key_from_reply_address(email) match_data = REPLY_ADDRESS_KEY_REGEXP.match(email) return unless match_data key = match_data[1] settings = find_service_desk_setting_from_reply_address(email, key) # We intentionally don't check whether custom email is enabled # so we don't lose emails that are addressed to a disabled custom email address return unless settings.present? key end |
.key_from_settings(email) ⇒ Object
Checks whether the given email is a custom email and returns the project’s mail key.
41 42 43 44 45 46 47 48 49 50 51 |
# File 'lib/gitlab/email/service_desk/custom_email.rb', line 41 def key_from_settings(email) return unless email.present? # Normalize custom email to also include verification emails. potential_custom_email = email.sub(ServiceDeskSetting::CUSTOM_EMAIL_VERIFICATION_SUBADDRESS, '') settings = ServiceDeskSetting.find_by_custom_email(potential_custom_email) return unless settings.present? settings.project.default_service_desk_subaddress_part end |
.reply_address(issue, reply_key) ⇒ Object
14 15 16 17 18 19 20 21 22 23 |
# File 'lib/gitlab/email/service_desk/custom_email.rb', line 14 def reply_address(issue, reply_key) return if reply_key.nil? custom_email = issue&.project&.service_desk_setting&.custom_email return if custom_email.nil? # Reply keys for custom email addresses always go before the @. # We don't have a placeholder. custom_email.sub('@', "+#{reply_key}@") end |