From 590e4e9c1c590e264206fe880cdb00da2a169220 Mon Sep 17 00:00:00 2001 From: Tejaswini Chile Date: Mon, 22 May 2023 13:51:56 +0530 Subject: [PATCH] Fix: prevent IMAPBadResponse exception from sending the authorization mail (#7154) --- app/jobs/inboxes/fetch_imap_emails_job.rb | 5 +++-- lib/exception_list.rb | 2 +- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/app/jobs/inboxes/fetch_imap_emails_job.rb b/app/jobs/inboxes/fetch_imap_emails_job.rb index 9f9393df7..8ffea6c18 100644 --- a/app/jobs/inboxes/fetch_imap_emails_job.rb +++ b/app/jobs/inboxes/fetch_imap_emails_job.rb @@ -7,9 +7,10 @@ class Inboxes::FetchImapEmailsJob < ApplicationJob return unless should_fetch_email?(channel) process_email_for_channel(channel) - rescue *ExceptionList::IMAP_EXCEPTIONS + rescue *ExceptionList::IMAP_EXCEPTIONS => e + Rails.logger.error e channel.authorization_error! - rescue EOFError, OpenSSL::SSL::SSLError => e + rescue EOFError, OpenSSL::SSL::SSLError, Net::IMAP::NoResponseError => e Rails.logger.error e rescue StandardError => e ChatwootExceptionTracker.new(e, account: channel.account).capture_exception diff --git a/lib/exception_list.rb b/lib/exception_list.rb index fccc747c6..2fee0a170 100644 --- a/lib/exception_list.rb +++ b/lib/exception_list.rb @@ -12,7 +12,7 @@ module ExceptionList ].freeze IMAP_EXCEPTIONS = [ - Errno::ECONNREFUSED, Net::OpenTimeout, Net::IMAP::NoResponseError, + Errno::ECONNREFUSED, Net::OpenTimeout, Errno::ECONNRESET, Errno::ENETUNREACH, Net::IMAP::ByeResponseError, SocketError ].freeze