Skip to content

Commit

Permalink
wip
Browse files Browse the repository at this point in the history
  • Loading branch information
xquanluu committed Nov 7, 2023
1 parent fc48dcf commit 6e02268
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 5 deletions.
4 changes: 3 additions & 1 deletion app.js
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,8 @@ const {
lookupAppByPhoneNumber,
lookupCarrierBySid,
lookupSipGatewayBySid,
lookupSmppGatewayBySid
lookupSmppGatewayBySid,
lookupClientByAccountAndUsername
} = require('@jambonz/db-helpers')({
host: process.env.JAMBONES_MYSQL_HOST,
user: process.env.JAMBONES_MYSQL_USER,
Expand Down Expand Up @@ -107,6 +108,7 @@ app.locals = {
lookupCarrierBySid,
lookupSipGatewayBySid,
lookupSmppGatewayBySid,
lookupClientByAccountAndUsername,
queryCdrs,
queryCdrsSP,
queryAlerts,
Expand Down
9 changes: 5 additions & 4 deletions lib/routes/api/accounts.js
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,7 @@ router.get('/:sid/RegisteredSipUsers', async(req, res) => {
});

router.get('/:sid/RegisteredSipUsers/:client', async(req, res) => {
const {logger, registrar} = req.app.locals;
const {logger, registrar, lookupClientByAccountAndUsername} = req.app.locals;
const client = req.params.client;
try {
const account_sid = parseAccountSid(req);
Expand All @@ -173,14 +173,15 @@ router.get('/:sid/RegisteredSipUsers/:client', async(req, res) => {
throw new DbErrorBadRequest(`account not found for sid ${account_sid}`);
}
const user = await registrar.query(`${client}@${result[0].sip_realm}`);
const clientDb = await lookupClientByAccountAndUsername(account_sid, client);
res.status(200).json({
name: client,
contact: user ? user.contact : null,
expiryTime: user ? user.expiryTime : 0,
protocol: user ? user.protocol : null,
allow_direct_app_calling: user ? client.allow_direct_app_calling : 0,
allow_direct_queue_calling: user ? client.allow_direct_queue_calling : 0,
allow_direct_user_calling: user ? client.allow_direct_user_calling : 0,
allow_direct_app_calling: clientDb ? clientDb.allow_direct_app_calling : 0,
allow_direct_queue_calling: clientDb ? clientDb.allow_direct_queue_calling : 0,
allow_direct_user_calling: clientDb ? clientDb.allow_direct_user_calling : 0,
registered_status: user ? 'active' : 'inactive'
});
} catch (err) {
Expand Down

0 comments on commit 6e02268

Please sign in to comment.