chore: Handle twillio Down::ClientError (#8757)
Fixes: https://linear.app/chatwoot/issue/CW-2992/downclienterror-400-bad-request-downclienterror
This commit is contained in:
@@ -127,7 +127,7 @@ class Twilio::IncomingMessageService
|
|||||||
|
|
||||||
def download_attachment_file
|
def download_attachment_file
|
||||||
download_with_auth
|
download_with_auth
|
||||||
rescue Down::Error => e
|
rescue Down::Error, Down::ClientError => e
|
||||||
handle_download_attachment_error(e)
|
handle_download_attachment_error(e)
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -141,12 +141,10 @@ class Twilio::IncomingMessageService
|
|||||||
|
|
||||||
# This is just a temporary workaround since some users have not yet enabled media protection. We will remove this in the future.
|
# This is just a temporary workaround since some users have not yet enabled media protection. We will remove this in the future.
|
||||||
def handle_download_attachment_error(error)
|
def handle_download_attachment_error(error)
|
||||||
Rails.logger.info "Error downloading attachment from Twilio: #{error.message}"
|
Rails.logger.info "Error downloading attachment from Twilio: #{error.message}: Retrying"
|
||||||
if error.message.include?('401 Unauthorized')
|
Down.download(params[:MediaUrl0])
|
||||||
Down.download(params[:MediaUrl0])
|
rescue StandardError => e
|
||||||
else
|
Rails.logger.info "Error downloading attachment from Twilio: #{e.message}: Skipping"
|
||||||
ChatwootExceptionTracker.new(error, account: @inbox.account).capture_exception
|
nil
|
||||||
nil
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
Reference in New Issue
Block a user