mirror of
https://github.com/jambonz/jambonz-feature-server.git
synced 2025-12-20 08:40:38 +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;
|
||||
|
||||
Reference in New Issue
Block a user