mirror of
https://github.com/jambonz/jambonz-feature-server.git
synced 2026-01-25 02:07:56 +00:00
Compare commits
3 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
c25df2ad7e | ||
|
|
348fa4f654 | ||
|
|
fff52c930c |
@@ -26,8 +26,19 @@ router.post('/', async(req, res) => {
|
||||
|
||||
switch (target.type) {
|
||||
case 'phone':
|
||||
case 'teams':
|
||||
uri = `sip:${target.number}@${sbcAddress}`;
|
||||
to = target.number;
|
||||
if ('teams' === target.type) {
|
||||
const {lookupTeamsByAccount} = srf.locals.dbHelpers;
|
||||
const obj = await lookupTeamsByAccount(req.body.account_sid);
|
||||
if (!obj) throw new Error('dial to ms teams not allowed; account must first be configured with teams info');
|
||||
Object.assign(opts.headers, {
|
||||
'X-MS-Teams-FQDN': obj.ms_teams_fqdn,
|
||||
'X-MS-Teams-Tenant-FQDN': target.tenant || obj.tenant_fqdn
|
||||
});
|
||||
if (target.vmail === true) uri = `${uri};opaque=app:voicemail`;
|
||||
}
|
||||
break;
|
||||
case 'user':
|
||||
uri = `sip:${target.name}`;
|
||||
@@ -124,12 +135,14 @@ router.post('/', async(req, res) => {
|
||||
if (err instanceof SipError) {
|
||||
if ([486, 603].includes(err.status)) callStatus = CallStatus.Busy;
|
||||
else if (487 === err.status) callStatus = CallStatus.NoAnswer;
|
||||
sipLogger.info(`REST outdial failed with ${err.status}`);
|
||||
cs.emit('callStatusChange', {callStatus, sipStatus: err.status});
|
||||
if (sipLogger) sipLogger.info(`REST outdial failed with ${err.status}`);
|
||||
else console.log(`REST outdial failed with ${err.status}`);
|
||||
if (cs) cs.emit('callStatusChange', {callStatus, sipStatus: err.status});
|
||||
}
|
||||
else {
|
||||
cs.emit('callStatusChange', {callStatus, sipStatus: 500});
|
||||
sipLogger.error({err}, 'REST outdial failed');
|
||||
if (cs) cs.emit('callStatusChange', {callStatus, sipStatus: 500});
|
||||
if (sipLogger) sipLogger.error({err}, 'REST outdial failed');
|
||||
else console.error(err);
|
||||
}
|
||||
ep.destroy();
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
const Task = require('./task');
|
||||
const {TaskName, TaskPreconditions} = require('../utils/constants');
|
||||
const {TaskName, TaskPreconditions, CallStatus} = require('../utils/constants');
|
||||
|
||||
/**
|
||||
* Rejects an incoming call with user-specified status code and reason
|
||||
@@ -19,6 +19,7 @@ class TaskSipDecline extends Task {
|
||||
res.send(this.data.status, this.data.reason, {
|
||||
headers: this.headers
|
||||
});
|
||||
cs.emit('callStatusChange', {callStatus: CallStatus.Failed, sipStatus: this.data.status});
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -108,11 +108,11 @@ class SingleDialer extends Emitter {
|
||||
|
||||
this.ep = await ms.createEndpoint();
|
||||
this.logger.debug(`SingleDialer:exec - created endpoint ${this.ep.uuid}`);
|
||||
let promiseStreamConnected;
|
||||
let lastSdp;
|
||||
const connectStream = async(remoteSdp) => {
|
||||
// wait for previous re-invite to complete, if any
|
||||
if (promiseStreamConnected) await promiseStreamConnected.catch((err) => {});
|
||||
return promiseStreamConnected = this.ep.modify(remoteSdp);
|
||||
if (remoteSdp === lastSdp) return;
|
||||
lastSdp = remoteSdp;
|
||||
return this.ep.modify(remoteSdp);
|
||||
};
|
||||
|
||||
Object.assign(opts, {
|
||||
@@ -161,9 +161,9 @@ class SingleDialer extends Emitter {
|
||||
this.emit('callStatusChange', status);
|
||||
}
|
||||
});
|
||||
await connectStream(this.dlg.remote.sdp);
|
||||
this.dlg.callSid = this.callSid;
|
||||
this.inviteInProgress = null;
|
||||
this.dlg.callSid = this.callSid;
|
||||
await connectStream(this.dlg.remote.sdp);
|
||||
this.emit('callStatusChange', {sipStatus: 200, callStatus: CallStatus.InProgress});
|
||||
this.logger.debug(`SingleDialer:exec call connected: ${this.callSid}`);
|
||||
const connectTime = this.dlg.connectTime = moment();
|
||||
|
||||
14
package-lock.json
generated
14
package-lock.json
generated
@@ -1164,9 +1164,9 @@
|
||||
"integrity": "sha1-Bmlv43Wvt/68AI8oaCJWukEHWAE="
|
||||
},
|
||||
"drachtio-sip": {
|
||||
"version": "0.4.0",
|
||||
"resolved": "https://registry.npmjs.org/drachtio-sip/-/drachtio-sip-0.4.0.tgz",
|
||||
"integrity": "sha512-/HHK0KH8sfQxUuVrYwaaRxdCq7j6sAQMxzegqzGQeOULx2TNeYb9Bf2SF5AO59DpmYkQRc+ezuHX58EpN/SR7A==",
|
||||
"version": "0.4.1",
|
||||
"resolved": "https://registry.npmjs.org/drachtio-sip/-/drachtio-sip-0.4.1.tgz",
|
||||
"integrity": "sha512-XjrsVb4O5bjgAr/hWogFk8TLoSp2bbOKYhFAFRayiMs/w7PkYep5z5IOW+erbR8LgVDjZVfdGxjA0RPkI4QMvA==",
|
||||
"requires": {
|
||||
"debug": "^4.1.1",
|
||||
"merge": ">=1.2.1",
|
||||
@@ -1176,16 +1176,16 @@
|
||||
}
|
||||
},
|
||||
"drachtio-srf": {
|
||||
"version": "4.4.37",
|
||||
"resolved": "https://registry.npmjs.org/drachtio-srf/-/drachtio-srf-4.4.37.tgz",
|
||||
"integrity": "sha512-Z7MpHzee8z6gYVFgLRCqTC2Tt7d0v+EjDLhpZDLpEX0gMTs2Qey+VZ6QxO4CGyMrysZsLBZG5ZBNEifC2gBkHg==",
|
||||
"version": "4.4.39",
|
||||
"resolved": "https://registry.npmjs.org/drachtio-srf/-/drachtio-srf-4.4.39.tgz",
|
||||
"integrity": "sha512-wqiCe3nM8C9OJwllYVTMoYpVIjtWgX1TcyYy4y0b8jII9uhyB6CaK8aRfgzesZLJ6NTVlioS3a2Ic3e3Cmrkng==",
|
||||
"requires": {
|
||||
"async": "^1.4.2",
|
||||
"debug": "^3.2.6",
|
||||
"delegates": "^0.1.0",
|
||||
"deprecate": "^1.1.1",
|
||||
"drachtio-mw-registration-parser": "0.0.2",
|
||||
"drachtio-sip": "^0.4.0",
|
||||
"drachtio-sip": "^0.4.1",
|
||||
"lodash": "^4.17.20",
|
||||
"node-noop": "0.0.1",
|
||||
"only": "0.0.2",
|
||||
|
||||
@@ -34,7 +34,7 @@
|
||||
"debug": "^4.1.1",
|
||||
"deepcopy": "^2.1.0",
|
||||
"drachtio-fsmrf": "^2.0.1",
|
||||
"drachtio-srf": "^4.4.37",
|
||||
"drachtio-srf": "^4.4.39",
|
||||
"express": "^4.17.1",
|
||||
"ip": "^1.1.5",
|
||||
"jambonz-mw-registrar": "^0.1.3",
|
||||
|
||||
Reference in New Issue
Block a user