From 65ef4e6d6451dcca315df3a28bcf4fc279dd6a30 Mon Sep 17 00:00:00 2001 From: Hoan Luu Huu <110280845+xquanluu@users.noreply.github.com> Date: Fri, 12 Jul 2024 21:36:43 +0700 Subject: [PATCH] =?UTF-8?q?fix=20conference=20in=20feature=20server=20clus?= =?UTF-8?q?ter=20join,=20leave,=20end=20events=20are=20=E2=80=A6=20(#803)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * fix conference in feature server cluster join, leave, end events are missing original data * wip --- lib/middleware.js | 9 +++++++++ lib/tasks/conference.js | 3 ++- lib/tasks/task.js | 1 + 3 files changed, 12 insertions(+), 1 deletion(-) diff --git a/lib/middleware.js b/lib/middleware.js index a2270431..f5821659 100644 --- a/lib/middleware.js +++ b/lib/middleware.js @@ -352,6 +352,15 @@ module.exports = function(srf, logger) { direction: CallDirection.Inbound, traceId: rootSpan.traceId }); + // if transferred call contains callInfo, let update original data to newly created callInfo in this instance. + if (app.transferredCall && app.callInfo) { + req.locals.callInfo.callerName = app.callInfo.callerName; + req.locals.callInfo.from = app.callInfo.from; + req.locals.callInfo.to = app.callInfo.to; + req.locals.callInfo.originatingSipIp = app.callInfo.originatingSipIp; + req.locals.callInfo.originatingSipTrunkName = app.callInfo.originatingSipTrunkName; + delete app.callInfo; + } next(); } catch (err) { span.end(); diff --git a/lib/tasks/conference.js b/lib/tasks/conference.js index 479f6351..8b10eddd 100644 --- a/lib/tasks/conference.js +++ b/lib/tasks/conference.js @@ -6,6 +6,7 @@ const { normalizeJambones } = require('@jambonz/verb-specifications'); const makeTask = require('./make_task'); const bent = require('bent'); const assert = require('assert'); +const HttpRequestor = require('../utils/http-requestor'); const WAIT = 'wait'; const JOIN = 'join'; const START = 'start'; @@ -569,7 +570,7 @@ class Conference extends Task { _normalizeHook(cs, hook) { if (typeof hook === 'object') return hook; const url = hook.startsWith('/') ? - `${cs.application.requestor.baseUrl}${hook}` : + `${cs.application.requestor instanceof HttpRequestor ? cs.application.requestor.baseUrl : ''}${hook}` : hook; return { url } ; diff --git a/lib/tasks/task.js b/lib/tasks/task.js index 5b587e1d..25605b8d 100644 --- a/lib/tasks/task.js +++ b/lib/tasks/task.js @@ -278,6 +278,7 @@ class Task extends Emitter { delete obj.requestor; delete obj.notifier; obj.tasks = cs.getRemainingTaskData(); + obj.callInfo = cs.callInfo.toJSON(); if (opts && obj.tasks.length > 0) { const key = Object.keys(obj.tasks[0])[0]; Object.assign(obj.tasks[0][key], {_: opts});