mirror of
https://github.com/jambonz/jambonz-api-server.git
synced 2025-12-19 05:47:46 +00:00
feat get registered client status (#251)
This commit is contained in:
@@ -145,6 +145,7 @@ 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 {
|
||||
@@ -161,6 +162,29 @@ router.get('/:sid/RegisteredSipUsers', async(req, res) => {
|
||||
}
|
||||
});
|
||||
|
||||
router.get('/:sid/RegisteredSipUsers/:client', async(req, res) => {
|
||||
const {logger, registrar} = req.app.locals;
|
||||
const client = req.params.client;
|
||||
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 user = await registrar.query(`${client}@${result[0].sip_realm}`);
|
||||
res.status(200).json({
|
||||
name: client,
|
||||
contact: user ? user.contact : null,
|
||||
expiryTime: user ? user.expiryTime : 0,
|
||||
protocol: user ? user.protocol : null,
|
||||
registered_status: user ? 'active' : 'inactive'
|
||||
});
|
||||
} catch (err) {
|
||||
sysError(logger, res, err);
|
||||
}
|
||||
});
|
||||
|
||||
function coerceNumbers(callInfo) {
|
||||
if (Array.isArray(callInfo)) {
|
||||
return callInfo.map((ci) => {
|
||||
|
||||
@@ -44,7 +44,7 @@ tags:
|
||||
description: Least Cost Routing Routes operations
|
||||
- name: LcrCarrierSetEntries
|
||||
description: Least Cost Routing Carrier Set Entries operation
|
||||
- name: GoogleCustomVOices
|
||||
- name: GoogleCustomVoices
|
||||
description: Google Custom voices operation
|
||||
paths:
|
||||
/BetaInviteCodes:
|
||||
@@ -4188,6 +4188,27 @@ paths:
|
||||
type: array
|
||||
items:
|
||||
type: string
|
||||
/Accounts/{AccountSid}/RegisteredSipUsers/{Client}:
|
||||
parameters:
|
||||
- name: Client
|
||||
in: path
|
||||
required: true
|
||||
style: simple
|
||||
explode: false
|
||||
schema:
|
||||
type: string
|
||||
get:
|
||||
tags:
|
||||
- Accounts
|
||||
summary: retrieve registered client registration
|
||||
operationId: getRegisteredClient
|
||||
responses:
|
||||
200:
|
||||
description: registered client found
|
||||
content:
|
||||
application/json:
|
||||
schema:
|
||||
$ref: '#/components/schemas/RegisteredClient'
|
||||
/Lcrs:
|
||||
post:
|
||||
tags:
|
||||
@@ -5772,6 +5793,31 @@ components:
|
||||
- name
|
||||
- reported_usage
|
||||
- model
|
||||
RegisteredClient:
|
||||
type: object
|
||||
properties:
|
||||
name:
|
||||
type: string
|
||||
example: xhoaluu
|
||||
contact:
|
||||
type: string
|
||||
example: sip:0dluqjt6@od41sl9jfc9m.invalid;transport=ws
|
||||
expiryTime:
|
||||
type: number
|
||||
example: 1698981449173
|
||||
protocol:
|
||||
type: string
|
||||
example: wss
|
||||
registered_status:
|
||||
type: string
|
||||
enum:
|
||||
- active
|
||||
- inactive
|
||||
required:
|
||||
- speech_credential_sid
|
||||
- name
|
||||
- reported_usage
|
||||
- model
|
||||
|
||||
security:
|
||||
- bearerAuth: []
|
||||
Reference in New Issue
Block a user