chore: consider X-original-sender to create contact in case of group mail (#2841)
For emails forwarded from google groups, Google rewrites the FROM address to the group email and the original email will be available under X-Original-Sender. This PR enables chatwoot to handle this case. Fixes: #2715
This commit is contained in:
@@ -58,7 +58,7 @@ class SupportMailbox < ApplicationMailbox
|
||||
end
|
||||
|
||||
def find_or_create_contact
|
||||
@contact = @inbox.contacts.find_by(email: processed_mail.from.first)
|
||||
@contact = @inbox.contacts.find_by(email: @processed_mail.original_sender)
|
||||
if @contact.present?
|
||||
@contact_inbox = ContactInbox.find_by(inbox: @inbox, contact: @contact)
|
||||
else
|
||||
@@ -72,7 +72,7 @@ class SupportMailbox < ApplicationMailbox
|
||||
inbox: @inbox,
|
||||
contact_attributes: {
|
||||
name: identify_contact_name,
|
||||
email: processed_mail.from.first,
|
||||
email: @processed_mail.original_sender,
|
||||
additional_attributes: {
|
||||
source_id: "email:#{processed_mail.message_id}"
|
||||
}
|
||||
|
||||
@@ -82,6 +82,10 @@ class MailPresenter < SimpleDelegator
|
||||
@mail.from.map(&:downcase)
|
||||
end
|
||||
|
||||
def original_sender
|
||||
@mail['X-Original-Sender'].try(:value) || from.first
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
# forcing the encoding of the content to UTF-8 so as to be compatible with database and serializers
|
||||
|
||||
Reference in New Issue
Block a user