Feat/devices call other (#491)

* calls between clients on same domain

* wip

* wip

* wip

* wip
This commit is contained in:
Hoan Luu Huu
2023-10-20 18:45:13 +07:00
committed by GitHub
parent 7992bc6ca0
commit 24fccbdae5
4 changed files with 55 additions and 4 deletions

View File

@@ -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;