fix: find mail message by references (#7220)
This commit is contained in:
@@ -35,9 +35,9 @@ class Imap::ImapMailbox
|
||||
end
|
||||
|
||||
def find_conversation_by_in_reply_to
|
||||
return if in_reply_to.blank?
|
||||
return if in_reply_to.blank? && @inbound_mail.references.blank?
|
||||
|
||||
message = @inbox.messages.find_by(source_id: in_reply_to)
|
||||
message = @inbox.messages.find_by(source_id: in_reply_to) || find_message_by_references
|
||||
if message.nil?
|
||||
@inbox.conversations.where("additional_attributes->>'in_reply_to' = ?", in_reply_to).first
|
||||
else
|
||||
@@ -49,6 +49,20 @@ class Imap::ImapMailbox
|
||||
@inbound_mail.in_reply_to
|
||||
end
|
||||
|
||||
def find_message_by_references
|
||||
message_to_return = nil
|
||||
|
||||
return if @inbound_mail.references.blank?
|
||||
|
||||
references = @inbound_mail.references
|
||||
|
||||
references.each do |message_id|
|
||||
message = @inbox.messages.find_by(source_id: message_id)
|
||||
message_to_return = message if message.present?
|
||||
end
|
||||
message_to_return
|
||||
end
|
||||
|
||||
def find_or_create_conversation
|
||||
@conversation = find_conversation_by_in_reply_to || ::Conversation.create!({ account_id: @account.id,
|
||||
inbox_id: @inbox.id,
|
||||
|
||||
Reference in New Issue
Block a user