mirror of
https://dev.azure.com/globalhealthx/EMR/_git/helix-engage-server
synced 2026-04-11 18:08:16 +00:00
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) <noreply@anthropic.com>
This commit is contained in:
@@ -112,6 +112,7 @@ export class OzonetelAgentController {
|
|||||||
@Body() body: {
|
@Body() body: {
|
||||||
ucid: string;
|
ucid: string;
|
||||||
disposition: string;
|
disposition: string;
|
||||||
|
agentId?: string;
|
||||||
callerPhone?: string;
|
callerPhone?: string;
|
||||||
direction?: string;
|
direction?: string;
|
||||||
durationSec?: number;
|
durationSec?: number;
|
||||||
@@ -124,16 +125,17 @@ export class OzonetelAgentController {
|
|||||||
throw new HttpException('ucid and disposition required', 400);
|
throw new HttpException('ucid and disposition required', 400);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const agentId = body.agentId ?? this.defaultAgentId;
|
||||||
const ozonetelDisposition = this.mapToOzonetelDisposition(body.disposition);
|
const ozonetelDisposition = this.mapToOzonetelDisposition(body.disposition);
|
||||||
|
|
||||||
// Cancel the ACW auto-dispose timer — the frontend submitted 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 {
|
try {
|
||||||
const result = await this.ozonetelAgent.setDisposition({
|
const result = await this.ozonetelAgent.setDisposition({
|
||||||
agentId: this.defaultAgentId,
|
agentId,
|
||||||
ucid: body.ucid,
|
ucid: body.ucid,
|
||||||
disposition: ozonetelDisposition,
|
disposition: ozonetelDisposition,
|
||||||
});
|
});
|
||||||
@@ -198,11 +200,10 @@ export class OzonetelAgentController {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const agentId = body.agentId ?? this.defaultAgentId;
|
const agentId = body.agentId ?? this.defaultAgentId;
|
||||||
|
const did = this.telephony.getConfig().ozonetel.did;
|
||||||
const campaignName = body.campaignName
|
const campaignName = body.campaignName
|
||||||
?? this.telephony.getConfig().ozonetel.campaignName
|
|| this.telephony.getConfig().ozonetel.campaignName
|
||||||
?? this.telephony.getConfig().ozonetel.did
|
|| (did ? `Inbound_${did}` : '');
|
||||||
? `Inbound_${this.telephony.getConfig().ozonetel.did}`
|
|
||||||
: '';
|
|
||||||
|
|
||||||
if (!campaignName) {
|
if (!campaignName) {
|
||||||
throw new HttpException('Campaign name not configured — set in Telephony settings or pass campaignName', 400);
|
throw new HttpException('Campaign name not configured — set in Telephony settings or pass campaignName', 400);
|
||||||
|
|||||||
Reference in New Issue
Block a user