feat: carrier register status (#141)

* feat: carrier register status

* update homer to query register pcap

* fix: homer

* fix: remove homer changes

* fix: homer issue
This commit is contained in:
Hoan Luu Huu
2023-04-04 00:21:38 +07:00
committed by GitHub
parent efe7e22109
commit 3ad19eca3c
3 changed files with 26 additions and 2 deletions
+10
View File
@@ -11,10 +11,16 @@ class VoipCarrier extends Model {
static async retrieveAll(account_sid) {
if (!account_sid) return super.retrieveAll();
const [rows] = await promisePool.query(retrieveSql, account_sid);
if (rows) {
rows.map((r) => r.register_status = JSON.parse(r.register_status || '{}'));
}
return rows;
}
static async retrieveAllForSP(service_provider_sid) {
const [rows] = await promisePool.query(retrieveSqlForSP, service_provider_sid);
if (rows) {
rows.map((r) => r.register_status = JSON.parse(r.register_status || '{}'));
}
return rows;
}
}
@@ -122,6 +128,10 @@ VoipCarrier.fields = [
{
name: 'register_public_ip_in_contact',
type: 'number'
},
{
name: 'register_status',
type: 'string'
}
];
+2
View File
@@ -89,6 +89,8 @@ router.get('/:sid', async(req, res) => {
const account_sid = req.user.hasAccountAuth ? req.user.account_sid : null;
const results = await VoipCarrier.retrieve(sid, account_sid);
if (results.length === 0) return res.status(404).end();
const ret = results[0];
ret.register_status = JSON.parse(ret.register_status || '{}');
return res.status(200).json(results[0]);
}
catch (err) {
+14 -2
View File
@@ -39,11 +39,17 @@ const getHomerSipTrace = async(logger, apiKey, callId) => {
const obj = await postJSON('/api/v3/call/transaction', {
param: {
transaction: {
call: true
call: true,
registration: true,
rest: false
},
orlogic: true,
search: {
'1_call': {
callid: [callId]
},
'1_registration': {
callid: [callId]
}
},
},
@@ -67,11 +73,17 @@ const getHomerPcap = async(logger, apiKey, callIds) => {
const stream = await postPcap('/api/v3/export/call/messages/pcap', {
param: {
transaction: {
call: true
call: true,
registration: true,
rest: false
},
orlogic: true,
search: {
'1_call': {
callid: callIds
},
'1_registration': {
callid: callIds
}
},
},