Feature/retrieve registered users (#243)

* add GET /Accounts/:sid/RegisteredSipUsers

* fix vulnerabilities
This commit is contained in:
Dave Horton
2023-10-22 17:32:59 +02:00
committed by GitHub
parent a1c302f85c
commit 7b805130bb
7 changed files with 425 additions and 307 deletions
+2
View File
@@ -25,6 +25,7 @@ const JAMBONES_REDIS_SENTINELS = process.env.JAMBONES_REDIS_SENTINELS ? {
} : null;
const {
client,
retrieveCall,
deleteCall,
listCalls,
@@ -42,6 +43,7 @@ const {
}, logger);
module.exports = {
client,
retrieveCall,
deleteCall,
listCalls,
+15
View File
@@ -145,6 +145,21 @@ router.post('/:sid/VoipCarriers', async(req, res) => {
sysError(logger, res, err);
}
});
router.get('/:sid/RegisteredSipUsers', async(req, res) => {
const {logger, registrar} = req.app.locals;
try {
const account_sid = parseAccountSid(req);
await validateRequest(req, account_sid);
const result = await Account.retrieve(account_sid);
if (!result || result.length === 0) {
throw new DbErrorBadRequest(`account not found for sid ${account_sid}`);
}
const users = await registrar.getRegisteredUsersForRealm(result[0].sip_realm);
res.status(200).json(users.map((u) => `${u}@${result[0].sip_realm}`));
} catch (err) {
sysError(logger, res, err);
}
});
function coerceNumbers(callInfo) {
if (Array.isArray(callInfo)) {
+22
View File
@@ -4164,6 +4164,28 @@ paths:
type: string
length:
type: string
/Accounts/{AccountSid}/RegisteredSipUsers:
parameters:
- name: AccountSid
in: path
required: true
schema:
type: string
format: uuid
get:
tags:
- Accounts
summary: retrieve online sip users for an account
operationId: listQueues
responses:
200:
description: retrieve online sip users for an account
content:
application/json:
schema:
type: array
items:
type: string
/Lcrs:
post:
tags: