mirror of
https://github.com/jambonz/jambonz-feature-server.git
synced 2025-12-20 16:50:39 +00:00
Feat/devices call other (#491)
* calls between clients on same domain * wip * wip * wip * wip
This commit is contained in:
@@ -20,7 +20,8 @@ module.exports = function(srf, logger) {
|
||||
lookupAppByRegex,
|
||||
lookupAppBySid,
|
||||
lookupAppByRealm,
|
||||
lookupAppByTeamsTenant
|
||||
lookupAppByTeamsTenant,
|
||||
registrar
|
||||
} = srf.locals.dbHelpers;
|
||||
const {
|
||||
writeAlerts,
|
||||
@@ -191,8 +192,37 @@ module.exports = function(srf, logger) {
|
||||
const sipRealm = arr[2];
|
||||
logger.debug(`looking for device calling app for realm ${sipRealm}`);
|
||||
app = await lookupAppByRealm(sipRealm);
|
||||
if (app) logger.debug({app}, `retrieved device calling app for realm ${sipRealm}`);
|
||||
|
||||
if (app) {
|
||||
logger.debug({app}, `retrieved device calling app for realm ${sipRealm}`);
|
||||
} else {
|
||||
const calledAor = `${req.calledNumber}@${sipRealm}`;
|
||||
const reg = await registrar.query(calledAor);
|
||||
if (reg) {
|
||||
logger.debug(`There is no device app found, called client is registered,
|
||||
forwarding call to called client.`);
|
||||
app = {
|
||||
// Dummy hook to follow later feature server logic.
|
||||
call_hook: {
|
||||
url: 'https://jambonz.org',
|
||||
method: 'GET'
|
||||
},
|
||||
account_sid,
|
||||
app_json: JSON.stringify(
|
||||
[{
|
||||
verb: 'dial',
|
||||
callerId: arr[1],
|
||||
answerOnBridge: true,
|
||||
target: [
|
||||
{
|
||||
type: 'user',
|
||||
name: calledAor
|
||||
}
|
||||
]
|
||||
}]
|
||||
)
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (req.locals.msTeamsTenant) {
|
||||
@@ -257,7 +287,7 @@ module.exports = function(srf, logger) {
|
||||
app2.requestor = new HttpRequestor(logger, account_sid, app.call_hook, accountInfo.account.webhook_secret);
|
||||
if (app.call_status_hook) app2.notifier = new HttpRequestor(logger, account_sid, app.call_status_hook,
|
||||
accountInfo.account.webhook_secret);
|
||||
else app2.notifier = {request: () => {}};
|
||||
else app2.notifier = {request: () => {}, close: () => {}};
|
||||
}
|
||||
|
||||
req.locals.application = app2;
|
||||
|
||||
@@ -17,6 +17,7 @@ const {
|
||||
PORT,
|
||||
NODE_ENV,
|
||||
} = require('../config');
|
||||
const Registrar = require('@jambonz/mw-registrar');
|
||||
const assert = require('assert');
|
||||
|
||||
function initMS(logger, wrapper, ms) {
|
||||
@@ -177,6 +178,7 @@ function installSrfLocals(srf, logger) {
|
||||
host: JAMBONES_REDIS_HOST,
|
||||
port: JAMBONES_REDIS_PORT || 6379
|
||||
}, logger, tracer);
|
||||
const registrar = new Registrar(logger, client);
|
||||
const {
|
||||
synthAudio,
|
||||
getNuanceAccessToken,
|
||||
@@ -204,6 +206,7 @@ function installSrfLocals(srf, logger) {
|
||||
srf.locals = {...srf.locals,
|
||||
dbHelpers: {
|
||||
client,
|
||||
registrar,
|
||||
pool,
|
||||
lookupAppByPhoneNumber,
|
||||
lookupAppByRegex,
|
||||
|
||||
Reference in New Issue
Block a user