Some checks failed
Lock Threads / action (push) Has been cancelled
Mark stale issues and pull requests / stale (push) Has been cancelled
Publish Chatwoot EE docker images / build (linux/amd64, ubuntu-latest) (push) Has been cancelled
Publish Chatwoot EE docker images / build (linux/arm64, ubuntu-22.04-arm) (push) Has been cancelled
Publish Chatwoot EE docker images / merge (push) Has been cancelled
Publish Chatwoot CE docker images / build (linux/amd64, ubuntu-latest) (push) Has been cancelled
Publish Chatwoot CE docker images / build (linux/arm64, ubuntu-22.04-arm) (push) Has been cancelled
Publish Chatwoot CE docker images / merge (push) Has been cancelled
Run Chatwoot CE spec / lint-backend (push) Has been cancelled
Run Chatwoot CE spec / lint-frontend (push) Has been cancelled
Run Chatwoot CE spec / frontend-tests (push) Has been cancelled
Run Chatwoot CE spec / backend-tests (0, 16) (push) Has been cancelled
Run Chatwoot CE spec / backend-tests (1, 16) (push) Has been cancelled
Run Chatwoot CE spec / backend-tests (10, 16) (push) Has been cancelled
Run Chatwoot CE spec / backend-tests (11, 16) (push) Has been cancelled
Run Chatwoot CE spec / backend-tests (12, 16) (push) Has been cancelled
Run Chatwoot CE spec / backend-tests (13, 16) (push) Has been cancelled
Run Chatwoot CE spec / backend-tests (14, 16) (push) Has been cancelled
Run Chatwoot CE spec / backend-tests (15, 16) (push) Has been cancelled
Run Chatwoot CE spec / backend-tests (2, 16) (push) Has been cancelled
Run Chatwoot CE spec / backend-tests (3, 16) (push) Has been cancelled
Run Chatwoot CE spec / backend-tests (4, 16) (push) Has been cancelled
Run Chatwoot CE spec / backend-tests (5, 16) (push) Has been cancelled
Run Chatwoot CE spec / backend-tests (6, 16) (push) Has been cancelled
Run Chatwoot CE spec / backend-tests (7, 16) (push) Has been cancelled
Run Chatwoot CE spec / backend-tests (8, 16) (push) Has been cancelled
Run Chatwoot CE spec / backend-tests (9, 16) (push) Has been cancelled
Run Linux nightly installer / nightly (push) Has been cancelled
- Add Logistics component with progress tracking - Add OrderDetail component for order information - Support data-driven steps and actions - Add blue color scale to widget SCSS - Fix node overflow and progress bar rendering issues - Add English translations for dashboard components Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
41 lines
1.4 KiB
Ruby
41 lines
1.4 KiB
Ruby
class ApplicationMailbox < ActionMailbox::Base
|
|
include MailboxHelper
|
|
|
|
# Last part is the regex for the UUID
|
|
# Eg: email should be something like : reply+6bdc3f4d-0bec-4515-a284-5d916fdde489@domain.com
|
|
REPLY_EMAIL_UUID_PATTERN = /^reply\+([0-9a-f]{8}\b-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-\b[0-9a-f]{12})$/i
|
|
|
|
# Route all emails to verified channels to the unified reply mailbox
|
|
# The ConversationFinder will determine if it's a reply or new conversation
|
|
routing(
|
|
lambda { |inbound_mail|
|
|
valid_to_address?(inbound_mail) &&
|
|
(reply_uuid_mail?(inbound_mail) || EmailChannelFinder.new(inbound_mail.mail).perform.present?)
|
|
} => :reply
|
|
)
|
|
|
|
# catchall
|
|
routing(all: :default)
|
|
|
|
class << self
|
|
# checks if follows this pattern: reply+<conversation-uuid>@<mailer-domain.com>
|
|
def reply_uuid_mail?(inbound_mail)
|
|
inbound_mail.mail.to&.any? do |email|
|
|
conversation_uuid = email.split('@')[0]
|
|
conversation_uuid.match?(REPLY_EMAIL_UUID_PATTERN)
|
|
end
|
|
end
|
|
|
|
# if mail.to returns a string, then it is a malformed `to` header
|
|
# valid `to` header will be of type Mail::AddressContainer
|
|
# validate if the to address is of type string
|
|
def valid_to_address?(inbound_mail)
|
|
to_address_class = inbound_mail.mail.to&.class
|
|
return true if to_address_class == Mail::AddressContainer
|
|
|
|
Rails.logger.error "Email to address header is malformed `#{inbound_mail.mail.to}`"
|
|
false
|
|
end
|
|
end
|
|
end
|