diff --git a/lib/models/voip-carrier.js b/lib/models/voip-carrier.js index 9f6b05a..9f342dc 100644 --- a/lib/models/voip-carrier.js +++ b/lib/models/voip-carrier.js @@ -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' } ]; diff --git a/lib/routes/api/voip-carriers.js b/lib/routes/api/voip-carriers.js index 5a9b43d..d80e630 100644 --- a/lib/routes/api/voip-carriers.js +++ b/lib/routes/api/voip-carriers.js @@ -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) { diff --git a/lib/utils/homer-utils.js b/lib/utils/homer-utils.js index 3f80e3e..7d73178 100644 --- a/lib/utils/homer-utils.js +++ b/lib/utils/homer-utils.js @@ -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 } }, },