From 9665500b6351e75785015e2df54dd422cd86c31b Mon Sep 17 00:00:00 2001 From: saridsa2 Date: Fri, 10 Apr 2026 15:49:10 +0530 Subject: [PATCH] fix: dispose uses per-agent ID + campaign fallback operator precedence Dispose endpoint now accepts agentId from body (same pattern as dial fix). Fixes "Invalid Agent ID" when disposing as non-default agent. Also fixed JS operator precedence bug in campaign name fallback that produced "Inbound_" instead of "Inbound_918041763400". Co-Authored-By: Claude Opus 4.6 (1M context) --- src/ozonetel/ozonetel-agent.controller.ts | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/src/ozonetel/ozonetel-agent.controller.ts b/src/ozonetel/ozonetel-agent.controller.ts index e574056..8aabd3b 100644 --- a/src/ozonetel/ozonetel-agent.controller.ts +++ b/src/ozonetel/ozonetel-agent.controller.ts @@ -112,6 +112,7 @@ export class OzonetelAgentController { @Body() body: { ucid: string; disposition: string; + agentId?: string; callerPhone?: string; direction?: string; durationSec?: number; @@ -124,16 +125,17 @@ export class OzonetelAgentController { throw new HttpException('ucid and disposition required', 400); } + const agentId = body.agentId ?? this.defaultAgentId; const ozonetelDisposition = this.mapToOzonetelDisposition(body.disposition); // Cancel the ACW auto-dispose timer — the frontend submitted disposition - this.supervisor.cancelAcwTimer(this.defaultAgentId); + this.supervisor.cancelAcwTimer(agentId); - this.logger.log(`[DISPOSE] ucid=${body.ucid} disposition=${body.disposition} → ozonetel="${ozonetelDisposition}" agentId=${this.defaultAgentId} callerPhone=${body.callerPhone ?? 'none'} direction=${body.direction ?? 'unknown'} leadId=${body.leadId ?? 'none'}`); + this.logger.log(`[DISPOSE] ucid=${body.ucid} disposition=${body.disposition} → ozonetel="${ozonetelDisposition}" agentId=${agentId} callerPhone=${body.callerPhone ?? 'none'} direction=${body.direction ?? 'unknown'} leadId=${body.leadId ?? 'none'}`); try { const result = await this.ozonetelAgent.setDisposition({ - agentId: this.defaultAgentId, + agentId, ucid: body.ucid, disposition: ozonetelDisposition, }); @@ -198,11 +200,10 @@ export class OzonetelAgentController { } const agentId = body.agentId ?? this.defaultAgentId; + const did = this.telephony.getConfig().ozonetel.did; const campaignName = body.campaignName - ?? this.telephony.getConfig().ozonetel.campaignName - ?? this.telephony.getConfig().ozonetel.did - ? `Inbound_${this.telephony.getConfig().ozonetel.did}` - : ''; + || this.telephony.getConfig().ozonetel.campaignName + || (did ? `Inbound_${did}` : ''); if (!campaignName) { throw new HttpException('Campaign name not configured — set in Telephony settings or pass campaignName', 400);