From 28415dc750edfbb4b2df2749ada19e08864ef24a Mon Sep 17 00:00:00 2001 From: Dave Horton Date: Mon, 30 Aug 2021 17:12:00 -0400 Subject: [PATCH] bugfixes for queue events --- .eslintrc.json | 2 +- lib/session/call-session.js | 7 ++++++- lib/session/confirm-call-session.js | 5 +++-- lib/tasks/enqueue.js | 1 + 4 files changed, 11 insertions(+), 4 deletions(-) diff --git a/.eslintrc.json b/.eslintrc.json index 03e3cfe3..fecc21ee 100644 --- a/.eslintrc.json +++ b/.eslintrc.json @@ -8,7 +8,7 @@ "jsx": false, "modules": false }, - "ecmaVersion": 2018 + "ecmaVersion": 2020 }, "plugins": ["promise"], "rules": { diff --git a/lib/session/call-session.js b/lib/session/call-session.js index 75e397a8..f33efff1 100644 --- a/lib/session/call-session.js +++ b/lib/session/call-session.js @@ -192,6 +192,10 @@ class CallSession extends Emitter { return this.constructor.name === 'SmsCallSession'; } + get webhook_secret() { + return this.accountInfo?.account?.webhook_secret; + } + /** * Check for speech credentials for the specified vendor * @param {*} vendor - google or aws @@ -784,7 +788,8 @@ class CallSession extends Emitter { } else { this.logger.info({accountSid: this.accountSid, webhook: r[0]}, 'performQueueWebhook: webhook found'); - this.queueEventHookRequestor = new Requestor(this.logger, r[0]); + this.queueEventHookRequestor = new Requestor(this.logger, this.accountSid, + r[0], this.webhook_secret); this.queueEventHook = r[0]; } } catch (err) { diff --git a/lib/session/confirm-call-session.js b/lib/session/confirm-call-session.js index 5f76e8bc..fca38f83 100644 --- a/lib/session/confirm-call-session.js +++ b/lib/session/confirm-call-session.js @@ -8,14 +8,15 @@ const CallSession = require('./call-session'); */ class ConfirmCallSession extends CallSession { - constructor({logger, application, dlg, ep, tasks, callInfo}) { + constructor({logger, application, dlg, ep, tasks, callInfo, accountInfo}) { super({ logger, application, srf: dlg.srf, callSid: dlg.callSid, tasks, - callInfo + callInfo, + accountInfo }); this.dlg = dlg; this.ep = ep; diff --git a/lib/tasks/enqueue.js b/lib/tasks/enqueue.js index bc5c6af2..3a2d14fd 100644 --- a/lib/tasks/enqueue.js +++ b/lib/tasks/enqueue.js @@ -346,6 +346,7 @@ class TaskEnqueue extends Task { dlg, ep: cs.ep, callInfo: cs.callInfo, + accountInfo: cs.accountInfo, tasks: tasksToRun }); await this._playSession.exec();