bugfix: invites to the PSTN and to webrtc clients

This commit is contained in:
Dave Horton
2020-05-11 09:16:42 -04:00
parent 96906bd0ad
commit e213409dec
+18 -3
View File
@@ -58,8 +58,14 @@ class CallSession extends Emitter {
debug(`connecting call: ${JSON.stringify(this.req.locals)}`);
if (this.req.locals.registration) {
debug(`sending call to user ${JSON.stringify(this.req.locals.registration)}`);
proxy = this.req.locals.registration.contact;
uris = [this.req.uri];
const contact = this.req.locals.registration.contact;
if (contact.includes('transport=ws')) {
uris = [contact];
}
else {
proxy = this.req.locals.registration.contact;
uris = [this.req.uri];
}
}
else if (this.req.locals.target === 'forward') {
uris = [this.req.uri];
@@ -73,6 +79,11 @@ class CallSession extends Emitter {
this.req.calledNumber;
uris = await this.performLcr(routableNumber);
if (!uris || uris.length === 0) throw new Error('no routes found');
uris = uris.map((uri) => {
this.logger.debug(`uri: ${uri}`);
const arr = /^(.*):(\d+)$/.exec(uri);
return arr ? `sip:${routableNumber}@${arr[1]}:${arr[2]}` : uri;
});
} catch (err) {
debug(err);
this.logger.error(err, 'Error performing lcr');
@@ -243,7 +254,11 @@ class CallSession extends Emitter {
res.send(202);
// invite to new fs
const dlg = await this.srf.createUAC(referTo.uri, {localSdp: dlg.local.sdp});
const headers = {};
if (req.has('X-Retain-Call-Sid')) {
Object.assign(headers, {'X-Retain-Call-Sid': req.get('X-Retain-Call-Sid')});
}
const dlg = await this.srf.createUAC(referTo.uri, {localSdp: dlg.local.sdp, proxyRequestHeaders});
this.uas.destroy();
this.uas = dlg;