mirror of
https://github.com/jambonz/jambonz-feature-server.git
synced 2025-12-20 08:40:38 +00:00
many changes from testing
This commit is contained in:
@@ -5,6 +5,13 @@ const {TaskPreconditions, CallDirection} = require('../utils/constants');
|
||||
const CallInfo = require('../session/call-info');
|
||||
const assert = require('assert');
|
||||
const ConfirmCallSession = require('../session/confirm-call-session');
|
||||
const selectSbc = require('./select-sbc');
|
||||
const Registrar = require('jambonz-mw-registrar');
|
||||
const registrar = new Registrar({
|
||||
host: process.env.JAMBONES_REDIS_HOST,
|
||||
port: process.env.JAMBONES_REDIS_PORT || 6379
|
||||
});
|
||||
|
||||
const moment = require('moment');
|
||||
const uuidv4 = require('uuid/v4');
|
||||
|
||||
@@ -52,28 +59,39 @@ class SingleDialer extends Emitter {
|
||||
|
||||
async exec(srf, ms, opts) {
|
||||
let uri, to;
|
||||
switch (this.target.type) {
|
||||
case 'phone':
|
||||
assert(this.target.number);
|
||||
uri = `sip:${this.target.number}@${this.sbcAddress}`;
|
||||
to = this.target.number;
|
||||
break;
|
||||
case 'user':
|
||||
assert(this.target.name);
|
||||
uri = `sip:${this.target.name}`;
|
||||
to = this.target.name;
|
||||
break;
|
||||
case 'sip':
|
||||
assert(this.target.sipUri);
|
||||
uri = this.target.sipUri;
|
||||
to = this.target.sipUri;
|
||||
break;
|
||||
default:
|
||||
// should have been caught by parser
|
||||
assert(false, `invalid dial type ${this.target.type}: must be phone, user, or sip`);
|
||||
}
|
||||
|
||||
try {
|
||||
switch (this.target.type) {
|
||||
case 'phone':
|
||||
assert(this.target.number);
|
||||
uri = `sip:${this.target.number}@${this.sbcAddress}`;
|
||||
to = this.target.number;
|
||||
break;
|
||||
case 'user':
|
||||
assert(this.target.name);
|
||||
const aor = this.target.name;
|
||||
uri = `sip:${this.target.name}`;
|
||||
to = this.target.name;
|
||||
|
||||
// need to send to the SBC registered on
|
||||
const reg = await registrar.query(aor);
|
||||
if (reg) {
|
||||
const sbc = selectSbc(reg.sbcAddress);
|
||||
if (sbc) {
|
||||
this.logger.debug(`SingleDialer:exec retrieved registration details for ${aor}, using sbc at ${sbc}`);
|
||||
this.sbcAddress = sbc;
|
||||
}
|
||||
}
|
||||
break;
|
||||
case 'sip':
|
||||
assert(this.target.sipUri);
|
||||
uri = this.target.sipUri;
|
||||
to = this.target.sipUri;
|
||||
break;
|
||||
default:
|
||||
// should have been caught by parser
|
||||
assert(false, `invalid dial type ${this.target.type}: must be phone, user, or sip`);
|
||||
}
|
||||
|
||||
this.updateCallStatus = srf.locals.dbHelpers.updateCallStatus;
|
||||
this.serviceUrl = srf.locals.serviceUrl;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user