From 40d3ec99dc7030173281ff2f0a1d4886ccab79a6 Mon Sep 17 00:00:00 2001 From: Tanmay Deep Sharma Date: Wed, 6 May 2026 15:23:42 +0700 Subject: [PATCH] fix(voice): require conversation to belong to dialed contact Reject conversation_id hints that point to a different contact in the same voice inbox, so reuse only happens when the agent is genuinely inside the open thread for the dialed contact. --- .../api/v1/accounts/contacts/calls_controller.rb | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/enterprise/app/controllers/api/v1/accounts/contacts/calls_controller.rb b/enterprise/app/controllers/api/v1/accounts/contacts/calls_controller.rb index 88290a999..64c41993b 100644 --- a/enterprise/app/controllers/api/v1/accounts/contacts/calls_controller.rb +++ b/enterprise/app/controllers/api/v1/accounts/contacts/calls_controller.rb @@ -41,11 +41,14 @@ class Api::V1::Accounts::Contacts::CallsController < Api::V1::Accounts::BaseCont end # Reuse the open conversation when the caller is already inside it; ignore - # the hint if it doesn't belong to the picked voice inbox. + # the hint if it doesn't belong to the picked voice inbox or dialed contact. def existing_conversation return nil if params[:conversation_id].blank? conversation = Current.account.conversations.find_by(display_id: params[:conversation_id]) - conversation if conversation && conversation.inbox_id == voice_inbox.id + return nil unless conversation + return nil unless conversation.inbox_id == voice_inbox.id && conversation.contact_id == contact.id + + conversation end end