Skip to content

Commit

Permalink
chore: Handle twillio Down::ClientError (#8757)
Browse files Browse the repository at this point in the history
  • Loading branch information
muhsin-k authored Jan 22, 2024
1 parent 1dc66db commit 682a2ae
Showing 1 changed file with 6 additions and 8 deletions.
14 changes: 6 additions & 8 deletions app/services/twilio/incoming_message_service.rb
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ def attach_files

def download_attachment_file
download_with_auth
rescue Down::Error => e
rescue Down::Error, Down::ClientError => e
handle_download_attachment_error(e)
end

Expand All @@ -141,12 +141,10 @@ def download_with_auth

# 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)
Rails.logger.info "Error downloading attachment from Twilio: #{error.message}"
if error.message.include?('401 Unauthorized')
Down.download(params[:MediaUrl0])
else
ChatwootExceptionTracker.new(error, account: @inbox.account).capture_exception
nil
end
Rails.logger.info "Error downloading attachment from Twilio: #{error.message}: Retrying"
Down.download(params[:MediaUrl0])
rescue StandardError => e
Rails.logger.info "Error downloading attachment from Twilio: #{e.message}: Skipping"
nil
end
end

1 comment on commit 682a2ae

@amesas
Copy link

@amesas amesas commented on 682a2ae Jan 24, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We have applied this patch to our installation.

It works, but if you have alrady the conversation open, you can't see the attached file until you reload the conversation page.

Please sign in to comment.