fix: Consider the emails where in-reply-to header has multiple values (#7715)
- Return the first message id for now to avoid the errors and subsequently missing the message. - Use .last instead of .first to avoid expensive query. - Fix array response in response bot. Fixes: https://linear.app/chatwoot/issue/CW-2358/activerecordstatementinvalid-pgdatatypemismatch-error-argument-of-and
This commit is contained in:
@@ -106,6 +106,15 @@ class MailPresenter < SimpleDelegator
|
||||
}
|
||||
end
|
||||
|
||||
def in_reply_to
|
||||
return if @mail.in_reply_to.blank?
|
||||
|
||||
# Although the "in_reply_to" field in the email can potentially hold multiple values,
|
||||
# our current system does not have the capability to handle this.
|
||||
# FIX ME: Address this issue by returning the complete results and utilizing them for querying conversations.
|
||||
@mail.in_reply_to.is_a?(Array) ? @mail.in_reply_to.first : @mail.in_reply_to
|
||||
end
|
||||
|
||||
def from
|
||||
# changing to downcase to avoid case mismatch while finding contact
|
||||
(@mail.reply_to.presence || @mail.from).map(&:downcase)
|
||||
|
||||
@@ -17,7 +17,7 @@ json.meta do
|
||||
end
|
||||
|
||||
json.id conversation.display_id
|
||||
if conversation.messages.where(account_id: conversation.account_id).first.blank?
|
||||
if conversation.messages.where(account_id: conversation.account_id).last.blank?
|
||||
json.messages []
|
||||
else
|
||||
json.messages [
|
||||
|
||||
Reference in New Issue
Block a user