mirror of
https://github.com/jambonz/jambonz-feature-server.git
synced 2026-01-25 02:07:56 +00:00
Merge branch 'main' into feat/fd_1904
This commit is contained in:
@@ -1,7 +1,6 @@
|
|||||||
const Task = require('./task');
|
const Task = require('./task');
|
||||||
const {TaskName} = require('../utils/constants');
|
const {TaskName} = require('../utils/constants');
|
||||||
const WsRequestor = require('../utils/ws-requestor');
|
const WsRequestor = require('../utils/ws-requestor');
|
||||||
const URL = require('url');
|
|
||||||
const HttpRequestor = require('../utils/http-requestor');
|
const HttpRequestor = require('../utils/http-requestor');
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -10,6 +9,7 @@ const HttpRequestor = require('../utils/http-requestor');
|
|||||||
class TaskRedirect extends Task {
|
class TaskRedirect extends Task {
|
||||||
constructor(logger, opts) {
|
constructor(logger, opts) {
|
||||||
super(logger, opts);
|
super(logger, opts);
|
||||||
|
this.statusHook = opts.statusHook || false;
|
||||||
}
|
}
|
||||||
|
|
||||||
get name() { return TaskName.Redirect; }
|
get name() { return TaskName.Redirect; }
|
||||||
@@ -47,6 +47,30 @@ class TaskRedirect extends Task {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* update the notifier if a new statusHook was provided */
|
||||||
|
if (this.statusHook) {
|
||||||
|
this.logger.info(`TaskRedirect updating statusHook to ${this.statusHook}`);
|
||||||
|
try {
|
||||||
|
const oldNotifier = cs.application.notifier;
|
||||||
|
const isStatusHookAbsolute = cs.notifier?._isAbsoluteUrl(this.statusHook);
|
||||||
|
if (isStatusHookAbsolute) {
|
||||||
|
if (cs.notifier instanceof WsRequestor) {
|
||||||
|
cs.application.notifier = new WsRequestor(this.logger, cs.accountSid, {url: this.statusHook},
|
||||||
|
cs.accountInfo.account.webhook_secret);
|
||||||
|
} else {
|
||||||
|
cs.application.notifier = new HttpRequestor(this.logger, cs.accountSid, {url: this.statusHook},
|
||||||
|
cs.accountInfo.account.webhook_secret);
|
||||||
|
}
|
||||||
|
if (oldNotifier?.close) oldNotifier.close();
|
||||||
|
}
|
||||||
|
/* update the call_status_hook URL that gets passed to the notifier */
|
||||||
|
cs.application.call_status_hook = this.statusHook;
|
||||||
|
} catch (err) {
|
||||||
|
this.logger.info(err, `TaskRedirect error updating statusHook to ${this.statusHook}`);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
await this.performAction();
|
await this.performAction();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -118,6 +118,13 @@ class ActionHookDelayProcessor extends Emitter {
|
|||||||
this.logger.debug('ActionHookDelayProcessor#_onNoResponseTimer');
|
this.logger.debug('ActionHookDelayProcessor#_onNoResponseTimer');
|
||||||
this._noResponseTimer = null;
|
this._noResponseTimer = null;
|
||||||
|
|
||||||
|
/* check if endpoint is still available (call may have ended) */
|
||||||
|
if (!this.ep) {
|
||||||
|
this.logger.debug('ActionHookDelayProcessor#_onNoResponseTimer: endpoint is null, call may have ended');
|
||||||
|
this._active = false;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
/* get the next play or say action */
|
/* get the next play or say action */
|
||||||
const verb = this.actions[this._retryCount % this.actions.length];
|
const verb = this.actions[this._retryCount % this.actions.length];
|
||||||
|
|
||||||
@@ -129,8 +136,8 @@ class ActionHookDelayProcessor extends Emitter {
|
|||||||
this._taskInProgress.exec(this.cs, {ep: this.ep}).catch((err) => {
|
this._taskInProgress.exec(this.cs, {ep: this.ep}).catch((err) => {
|
||||||
this.logger.info(`ActionHookDelayProcessor#_onNoResponseTimer: error playing file: ${err.message}`);
|
this.logger.info(`ActionHookDelayProcessor#_onNoResponseTimer: error playing file: ${err.message}`);
|
||||||
this._taskInProgress = null;
|
this._taskInProgress = null;
|
||||||
this.ep.removeAllListeners('playback-start');
|
this.ep?.removeAllListeners('playback-start');
|
||||||
this.ep.removeAllListeners('playback-stop');
|
this.ep?.removeAllListeners('playback-stop');
|
||||||
});
|
});
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
this.logger.info(err, 'ActionHookDelayProcessor#_onNoResponseTimer: error starting action');
|
this.logger.info(err, 'ActionHookDelayProcessor#_onNoResponseTimer: error starting action');
|
||||||
|
|||||||
8
package-lock.json
generated
8
package-lock.json
generated
@@ -18,7 +18,7 @@
|
|||||||
"@jambonz/speech-utils": "^0.2.26",
|
"@jambonz/speech-utils": "^0.2.26",
|
||||||
"@jambonz/stats-collector": "^0.1.10",
|
"@jambonz/stats-collector": "^0.1.10",
|
||||||
"@jambonz/time-series": "^0.2.15",
|
"@jambonz/time-series": "^0.2.15",
|
||||||
"@jambonz/verb-specifications": "^0.0.123",
|
"@jambonz/verb-specifications": "^0.0.125",
|
||||||
"@modelcontextprotocol/sdk": "^1.9.0",
|
"@modelcontextprotocol/sdk": "^1.9.0",
|
||||||
"@opentelemetry/api": "^1.8.0",
|
"@opentelemetry/api": "^1.8.0",
|
||||||
"@opentelemetry/exporter-jaeger": "^1.23.0",
|
"@opentelemetry/exporter-jaeger": "^1.23.0",
|
||||||
@@ -1529,9 +1529,9 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"node_modules/@jambonz/verb-specifications": {
|
"node_modules/@jambonz/verb-specifications": {
|
||||||
"version": "0.0.123",
|
"version": "0.0.125",
|
||||||
"resolved": "https://registry.npmjs.org/@jambonz/verb-specifications/-/verb-specifications-0.0.123.tgz",
|
"resolved": "https://registry.npmjs.org/@jambonz/verb-specifications/-/verb-specifications-0.0.125.tgz",
|
||||||
"integrity": "sha512-yPW8u0Wacz8FKnQpQDjJ2AQHjHTf4S3TlkTyKqFkOyY8lnjnhqg0Mth+9uvOPfJaHgsPd0t9outfQa0wCu5tww==",
|
"integrity": "sha512-lU1fyyYyjXOdIfQ2gmOFmssZASYNu6LD066iXjqFrBJpiI7shkprcZ1qeWGibuEk9nR2k+em3/YL31Wc8L4wvA==",
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"debug": "^4.3.4",
|
"debug": "^4.3.4",
|
||||||
|
|||||||
@@ -34,7 +34,7 @@
|
|||||||
"@jambonz/speech-utils": "^0.2.26",
|
"@jambonz/speech-utils": "^0.2.26",
|
||||||
"@jambonz/stats-collector": "^0.1.10",
|
"@jambonz/stats-collector": "^0.1.10",
|
||||||
"@jambonz/time-series": "^0.2.15",
|
"@jambonz/time-series": "^0.2.15",
|
||||||
"@jambonz/verb-specifications": "^0.0.123",
|
"@jambonz/verb-specifications": "^0.0.125",
|
||||||
"@modelcontextprotocol/sdk": "^1.9.0",
|
"@modelcontextprotocol/sdk": "^1.9.0",
|
||||||
"@opentelemetry/api": "^1.8.0",
|
"@opentelemetry/api": "^1.8.0",
|
||||||
"@opentelemetry/exporter-jaeger": "^1.23.0",
|
"@opentelemetry/exporter-jaeger": "^1.23.0",
|
||||||
|
|||||||
Reference in New Issue
Block a user