In this PR https://github.com/chatwoot/chatwoot/pull/11139, if there is an attempt to create a duplication session for the contact in the same inbox, we will anonymize the old session. This PR would prevent sending messages to the older sessions. The support agents will have to create a new conversation to continue messages with customer.
23 lines
602 B
Ruby
23 lines
602 B
Ruby
class Api::V1::Accounts::Contacts::ContactInboxesController < Api::V1::Accounts::Contacts::BaseController
|
|
include HmacConcern
|
|
before_action :ensure_inbox, only: [:create]
|
|
|
|
def create
|
|
@contact_inbox = ContactInboxBuilder.new(
|
|
contact: @contact,
|
|
inbox: @inbox,
|
|
source_id: params[:source_id],
|
|
hmac_verified: hmac_verified?
|
|
).perform
|
|
rescue ArgumentError => e
|
|
render json: { error: e.message }, status: :unprocessable_entity
|
|
end
|
|
|
|
private
|
|
|
|
def ensure_inbox
|
|
@inbox = Current.account.inboxes.find(params[:inbox_id])
|
|
authorize @inbox, :show?
|
|
end
|
|
end
|