fix device call prioritize call to registered client first (#492)

This commit is contained in:
Hoan Luu Huu
2023-10-23 18:51:16 +07:00
committed by GitHub
parent 24fccbdae5
commit cf0f4d405f

View File

@@ -190,37 +190,36 @@ module.exports = function(srf, logger) {
const arr = /^(.*)@(.*)/.exec(req.locals.originatingUser);
if (arr) {
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}`);
const calledAor = `${req.calledNumber}@${sipRealm}`;
const reg = await registrar.query(calledAor);
if (reg) {
logger.debug(`called client ${calledAor} 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 {
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
}
]
}]
)
};
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}`);
}
}
}