mirror of
https://github.com/jambonz/jambonz-feature-server.git
synced 2025-12-20 08:40:38 +00:00
fix device call prioritize call to registered client first (#492)
This commit is contained in:
@@ -190,37 +190,36 @@ module.exports = function(srf, logger) {
|
|||||||
const arr = /^(.*)@(.*)/.exec(req.locals.originatingUser);
|
const arr = /^(.*)@(.*)/.exec(req.locals.originatingUser);
|
||||||
if (arr) {
|
if (arr) {
|
||||||
const sipRealm = arr[2];
|
const sipRealm = arr[2];
|
||||||
logger.debug(`looking for device calling app for realm ${sipRealm}`);
|
const calledAor = `${req.calledNumber}@${sipRealm}`;
|
||||||
app = await lookupAppByRealm(sipRealm);
|
const reg = await registrar.query(calledAor);
|
||||||
if (app) {
|
if (reg) {
|
||||||
logger.debug({app}, `retrieved device calling app for realm ${sipRealm}`);
|
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 {
|
} else {
|
||||||
const calledAor = `${req.calledNumber}@${sipRealm}`;
|
logger.debug(`looking for device calling app for realm ${sipRealm}`);
|
||||||
const reg = await registrar.query(calledAor);
|
app = await lookupAppByRealm(sipRealm);
|
||||||
if (reg) {
|
if (app) {
|
||||||
logger.debug(`There is no device app found, called client is registered,
|
logger.debug({app}, `retrieved device calling app for realm ${sipRealm}`);
|
||||||
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
|
|
||||||
}
|
|
||||||
]
|
|
||||||
}]
|
|
||||||
)
|
|
||||||
};
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user