mirror of
https://github.com/jambonz/jambonz-feature-server.git
synced 2026-02-13 17:59:42 +00:00
Compare commits
7 Commits
v0.9.6-rc3
...
fix/rest-d
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
968fa52eac | ||
|
|
99ad9de68e | ||
|
|
cf8d47cb94 | ||
|
|
2b4fc478b0 | ||
|
|
4b800a1479 | ||
|
|
c6af3c6a8b | ||
|
|
b88a9d4d4d |
@@ -796,7 +796,9 @@ class CallSession extends Emitter {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (0 === this.tasks.length && this.requestor instanceof WsRequestor && !this.callGone) {
|
if (0 === this.tasks.length && ((this.requestor instanceof WsRequestor && !this.callGone) ||
|
||||||
|
// Tasks are all done, but outgoing dialog is not establish yet, waiting for cancel/handup the call.
|
||||||
|
!this.dlg && !this.isFinalStatus() && this.direction === CallDirection.Outbound)) {
|
||||||
//let span;
|
//let span;
|
||||||
try {
|
try {
|
||||||
//const {span} = this.rootSpan.startChildSpan('waiting for commands');
|
//const {span} = this.rootSpan.startChildSpan('waiting for commands');
|
||||||
@@ -1790,6 +1792,16 @@ class CallSession extends Emitter {
|
|||||||
//this.logger.debug(`updating redis with ${JSON.stringify(this.callInfo)}`);
|
//this.logger.debug(`updating redis with ${JSON.stringify(this.callInfo)}`);
|
||||||
this.updateCallStatus(Object.assign({}, this.callInfo.toJSON()), this.serviceUrl)
|
this.updateCallStatus(Object.assign({}, this.callInfo.toJSON()), this.serviceUrl)
|
||||||
.catch((err) => this.logger.error(err, 'redis error'));
|
.catch((err) => this.logger.error(err, 'redis error'));
|
||||||
|
|
||||||
|
if (this.wakeupResolver && this.isFinalStatus()) {
|
||||||
|
// Someone is waiting for call to be final
|
||||||
|
this.wakeupResolver({reason: 'session ended'});
|
||||||
|
this.wakeupResolver = null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
isFinalStatus() {
|
||||||
|
return [CallStatus.Failed, CallStatus.Busy, CallStatus.NoAnswer, CallStatus.Completed].includes(this.callStatus);
|
||||||
}
|
}
|
||||||
|
|
||||||
async executeStatusCallback(callStatus, sipStatus) {
|
async executeStatusCallback(callStatus, sipStatus) {
|
||||||
|
|||||||
@@ -32,6 +32,7 @@ test('test create-call timeout', async(t) => {
|
|||||||
|
|
||||||
// GIVEN
|
// GIVEN
|
||||||
let account_sid = '622f62e4-303a-49f2-bbe0-eb1e1714e37a';
|
let account_sid = '622f62e4-303a-49f2-bbe0-eb1e1714e37a';
|
||||||
|
const from = "restdialtimeout";
|
||||||
const post = bent('http://127.0.0.1:3000/', 'POST', 'json', 201);
|
const post = bent('http://127.0.0.1:3000/', 'POST', 'json', 201);
|
||||||
post('v1/createCall', {
|
post('v1/createCall', {
|
||||||
'account_sid':account_sid,
|
'account_sid':account_sid,
|
||||||
@@ -40,13 +41,22 @@ test('test create-call timeout', async(t) => {
|
|||||||
"url": "https://public-apps.jambonz.us/hello-world",
|
"url": "https://public-apps.jambonz.us/hello-world",
|
||||||
"method": "POST"
|
"method": "POST"
|
||||||
},
|
},
|
||||||
"from": "15083718299",
|
"call_status_hook": {
|
||||||
|
"url": "http://127.0.0.1:3100/callStatus",
|
||||||
|
"method": "POST"
|
||||||
|
},
|
||||||
|
from,
|
||||||
"to": {
|
"to": {
|
||||||
"type": "phone",
|
"type": "phone",
|
||||||
"number": "15583084809"
|
"number": "15583084809"
|
||||||
}});
|
}});
|
||||||
//THEN
|
//THEN
|
||||||
await p;
|
await p;
|
||||||
|
|
||||||
|
let obj = await getJSON(`http:127.0.0.1:3100/lastRequest/${from}_callStatus`);
|
||||||
|
t.ok(obj.body.sip_reason = 'Request Terminated',
|
||||||
|
'create-call timeout: status callback successfully executed');
|
||||||
|
|
||||||
disconnect();
|
disconnect();
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
console.log(`error received: ${err}`);
|
console.log(`error received: ${err}`);
|
||||||
|
|||||||
@@ -15,5 +15,6 @@ require('./sip-refer-tests');
|
|||||||
require('./listen-tests');
|
require('./listen-tests');
|
||||||
require('./config-test');
|
require('./config-test');
|
||||||
require('./queue-test');
|
require('./queue-test');
|
||||||
|
require('./sip-decline-test');
|
||||||
require('./remove-test-db');
|
require('./remove-test-db');
|
||||||
require('./docker_stop');
|
require('./docker_stop');
|
||||||
56
test/sip-decline-test.js
Normal file
56
test/sip-decline-test.js
Normal file
@@ -0,0 +1,56 @@
|
|||||||
|
const test = require('tape');
|
||||||
|
const { sippUac } = require('./sipp')('test_fs');
|
||||||
|
const clearModule = require('clear-module');
|
||||||
|
const {provisionCallHook} = require('./utils');
|
||||||
|
const bent = require('bent');
|
||||||
|
const getJSON = bent('json');
|
||||||
|
|
||||||
|
process.on('unhandledRejection', (reason, p) => {
|
||||||
|
console.log('Unhandled Rejection at: Promise', p, 'reason:', reason);
|
||||||
|
});
|
||||||
|
|
||||||
|
function connect(connectable) {
|
||||||
|
return new Promise((resolve, reject) => {
|
||||||
|
connectable.on('connect', () => {
|
||||||
|
return resolve();
|
||||||
|
});
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
test('\'sip:decline\' tests', async(t) => {
|
||||||
|
clearModule.all();
|
||||||
|
const {srf, disconnect} = require('../app');
|
||||||
|
|
||||||
|
try {
|
||||||
|
await connect(srf);
|
||||||
|
|
||||||
|
// GIVEN
|
||||||
|
const verbs = [
|
||||||
|
{
|
||||||
|
"verb": "sip:decline",
|
||||||
|
"status": 480,
|
||||||
|
"reason": "Gone Fishing",
|
||||||
|
"headers" : {
|
||||||
|
"Retry-After": 1800
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
];
|
||||||
|
|
||||||
|
const from = 'sip_delecine_success';
|
||||||
|
await provisionCallHook(from, verbs)
|
||||||
|
|
||||||
|
// THEN
|
||||||
|
await sippUac('uac-invite-expect-480.xml', '172.38.0.10', from);
|
||||||
|
|
||||||
|
let obj = await getJSON(`http:127.0.0.1:3100/requests/${from}_callStatus`);
|
||||||
|
t.ok(obj.map((o) => o.body.call_status).includes('failed'),
|
||||||
|
'sip:decline: status callback successfully executed');
|
||||||
|
disconnect();
|
||||||
|
} catch (err) {
|
||||||
|
console.log(`error received: ${err}`);
|
||||||
|
disconnect();
|
||||||
|
t.error(err);
|
||||||
|
}
|
||||||
|
});
|
||||||
Reference in New Issue
Block a user