fix: sentry CHATWOOT-37A ActiveRecord::RecordNotUnique (#6496)

* fix: sentry CHATWOOT-37A #6457

* chore: add spec
---------

Co-authored-by: Sojan Jose <sojan@pepalo.com>
This commit is contained in:
Vishnu Narayanan
2023-02-21 09:34:51 +05:30
committed by GitHub
parent 62de25960c
commit 930863b25b
2 changed files with 13 additions and 1 deletions

View File

@@ -142,6 +142,8 @@ class Api::V1::Accounts::ConversationsController < Api::V1::Accounts::BaseContro
# and deprecate the support of passing only source_id as the param
@contact_inbox ||= ::ContactInbox.find_by!(source_id: params[:source_id])
authorize @contact_inbox.inbox, :show?
rescue ActiveRecord::RecordNotUnique
render json: { error: 'source_id should be unique' }, status: :unprocessable_entity
end
def build_contact_inbox