write service_provider_sid with alerts

This commit is contained in:
Dave Horton
2022-09-07 23:51:40 +02:00
parent e90ef6bc70
commit 889257d7db
14 changed files with 85 additions and 175 deletions

View File

@@ -21,8 +21,9 @@ class CallInfo {
// inbound call
const {app, req} = opts;
srf = req.srf;
this.callSid = req.locals.callSid,
this.accountSid = app.account_sid,
this.callSid = req.locals.callSid;
this.serviceProviderSid = req.locals.service_provider_sid;
this.accountSid = app.account_sid;
this.applicationSid = app.application_sid;
this.from = from || req.callingNumber;
this.to = req.calledNumber;
@@ -39,6 +40,7 @@ class CallInfo {
srf = req.srf;
this.callSid = callSid || uuidv4();
this.parentCallSid = parentCallInfo.callSid;
this.serviceProviderSid = parentCallInfo.serviceProviderSid;
this.accountSid = parentCallInfo.accountSid;
this.applicationSid = parentCallInfo.applicationSid;
this.from = from || req.callingNumber;
@@ -51,18 +53,20 @@ class CallInfo {
}
else if (this.direction === CallDirection.None) {
// outbound SMS
const {messageSid, accountSid, applicationSid, res} = opts;
const {messageSid, serviceProviderSid, accountSid, applicationSid, res} = opts;
srf = res.srf;
this.messageSid = messageSid;
this.serviceProviderSid = serviceProviderSid;
this.accountSid = accountSid;
this.applicationSid = applicationSid;
this.res = res;
}
else {
// outbound call triggered by REST
const {req, callSid, accountSid, applicationSid, to, tag} = opts;
const {req, callSid, accountSid, serviceProviderSid, applicationSid, to, tag} = opts;
srf = req.srf;
this.callSid = callSid;
this.serviceProviderSid = serviceProviderSid;
this.accountSid = accountSid;
this.applicationSid = applicationSid;
this.callStatus = CallStatus.Trying,

View File

@@ -201,6 +201,12 @@ class CallSession extends Emitter {
return this.direction === CallDirection.Inbound && this.res.finalResponseSent;
}
/**
* returns the account sid
*/
get serviceProviderSid() {
return this.callInfo.serviceProviderSid;
}
/**
* returns the account sid
*/
@@ -520,6 +526,7 @@ class CallSession extends Emitter {
this.logger.info({err}, `malformed google service_key provisioned for account ${sid}`);
writeAlerts({
alert_type: AlertType.TTS_FAILURE,
service_provider_sid: this.serviceProviderSid,
account_sid: this.accountSid,
vendor
}).catch((err) => this.logger.error({err}, 'Error writing tts alert'));
@@ -550,6 +557,7 @@ class CallSession extends Emitter {
else {
writeAlerts({
alert_type: AlertType.STT_NOT_PROVISIONED,
service_provider_sid: this.serviceProviderSid,
account_sid: this.accountSid,
vendor
}).catch((err) => this.logger.error({err}, 'Error writing tts alert'));
@@ -1382,8 +1390,13 @@ class CallSession extends Emitter {
}
else {
this.logger.info({accountSid: this.accountSid, webhook: r[0]}, 'performQueueWebhook: webhook found');
this.queueEventHookRequestor = new HttpRequestor(this.logger, this.accountSid,
r[0], this.webhook_secret);
this.queueEventHookRequestor = new HttpRequestor(
this.logger,
this.serviceProviderSid,
this.accountSid,
r[0],
this.webhook_secret
);
this.queueEventHook = r[0];
}
} catch (err) {