chore: Prevent notification email loop (#3386)
Configuring an agent email also as a support email inbox leads to conversations getting created in a loop if notifications were also configured to the same email.
This commit is contained in:
@@ -28,4 +28,9 @@ module MailboxHelper
|
||||
end
|
||||
@message.save!
|
||||
end
|
||||
|
||||
def notification_email_from_chatwoot?
|
||||
# notification emails are send via mailer sender email address. so it should match
|
||||
@processed_mail.original_sender == Mail::Address.new(ENV.fetch('MAILER_SENDER_EMAIL', 'Chatwoot <accounts@chatwoot.com>')).address
|
||||
end
|
||||
end
|
||||
|
||||
@@ -7,6 +7,9 @@ class SupportMailbox < ApplicationMailbox
|
||||
:decorate_mail
|
||||
|
||||
def process
|
||||
# prevent loop from chatwoot notification emails
|
||||
return if notification_email_from_chatwoot?
|
||||
|
||||
ActiveRecord::Base.transaction do
|
||||
find_or_create_contact
|
||||
find_or_create_conversation
|
||||
|
||||
Reference in New Issue
Block a user