From e1dad569dcd8fc46559dd329109b9f5833abae14 Mon Sep 17 00:00:00 2001 From: Hoan Luu Huu <110280845+xquanluu@users.noreply.github.com> Date: Tue, 11 Jul 2023 22:03:32 +0700 Subject: [PATCH] Fix/background listen tag (#391) * fix background listen send customerData to api server * test listen * fix review comment --- lib/session/call-session.js | 2 ++ lib/tasks/listen.js | 8 +++++++- 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/lib/session/call-session.js b/lib/session/call-session.js index 660d1ad7..271d8dec 100644 --- a/lib/session/call-session.js +++ b/lib/session/call-session.js @@ -513,6 +513,8 @@ class CallSession extends Emitter { const t = normalizeJambones(this.logger, [opts]); this.backgroundListenTask = makeTask(this.logger, t[0]); this.backgroundListenTask.bugname = bugname; + // Remove unneeded customer data to be sent to api server. + this.backgroundListenTask.ignoreCustomerData = true; const resources = await this._evaluatePreconditions(this.backgroundListenTask); const {span, ctx} = this.rootSpan.startChildSpan(`background-listen:${this.backgroundListenTask.summary}`); this.backgroundListenTask.span = span; diff --git a/lib/tasks/listen.js b/lib/tasks/listen.js index 58bbe9cb..6b22b69c 100644 --- a/lib/tasks/listen.js +++ b/lib/tasks/listen.js @@ -32,6 +32,8 @@ class TaskListen extends Task { set bugname(name) { this._bugname = name; } + set ignoreCustomerData(val) { this._ignoreCustomerData = val; } + async exec(cs, {ep}) { await super.exec(cs); this.ep = ep; @@ -111,9 +113,13 @@ class TaskListen extends Task { async _startListening(cs, ep) { this._initListeners(ep); + const ci = this.nested ? this.parentTask.sd.callInfo : cs.callInfo.toJSON(); + if (this._ignoreCustomerData) { + delete ci.customerData; + } const metadata = Object.assign( {sampleRate: this.sampleRate, mixType: this.mixType}, - this.nested ? this.parentTask.sd.callInfo : cs.callInfo.toJSON(), + ci, this.metadata); if (this.hook.auth) { this.logger.debug({username: this.hook.auth.username, password: this.hook.auth.password},