fix: Email date attribute not being set (#7081)

Fixes: https://linear.app/chatwoot/issue/CW-1738/typeerror-no-implicit-conversion-of-nil-into-string-typeerror
This commit is contained in:
Tejaswini Chile
2023-05-15 20:19:03 +05:30
committed by GitHub
parent d9f2cd0a6e
commit b994706265
3 changed files with 43 additions and 3 deletions

View File

@@ -9,7 +9,7 @@ class Inboxes::FetchImapEmailsJob < ApplicationJob
process_email_for_channel(channel)
rescue *ExceptionList::IMAP_EXCEPTIONS
channel.authorization_error!
rescue EOFError => e
rescue EOFError, OpenSSL::SSL::SSLError => e
Rails.logger.error e
rescue StandardError => e
ChatwootExceptionTracker.new(e, account: channel.account).capture_exception
@@ -87,8 +87,12 @@ class Inboxes::FetchImapEmailsJob < ApplicationJob
end
def last_email_time(channel)
time = 1.hour.ago.to_s
time = channel.inbox.messages.incoming.last.content_attributes['email']['date'] if channel.inbox.messages.any?
if channel.inbox.messages.any?
time = channel.inbox.messages.incoming.last.content_attributes['email']['date']
time ||= channel.inbox.messages.incoming.last.created_at.to_s
end
time ||= 1.hour.ago.to_s
DateTime.parse(time)
end