Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add metadata to create call as tag #338

Closed
wants to merge 7 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion lib/http-routes/api/create-call.js
Original file line number Diff line number Diff line change
Expand Up @@ -193,7 +193,7 @@ router.post('/', async(req, res) => {
direction: CallDirection.Outbound,
req: inviteReq,
to,
tag: app.tag,
tag: {...req.body.metadata, ...app.tag},
callSid,
accountSid: req.body.account_sid,
applicationSid: app.application_sid,
Expand Down
14 changes: 7 additions & 7 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
"@jambonz/speech-utils": "^0.0.12",
"@jambonz/stats-collector": "^0.1.8",
"@jambonz/time-series": "^0.2.5",
"@jambonz/verb-specifications": "^0.0.17",
"@jambonz/verb-specifications": "^0.0.18",
"@opentelemetry/api": "^1.4.0",
"@opentelemetry/exporter-jaeger": "^1.9.0",
"@opentelemetry/exporter-trace-otlp-http": "^0.35.0",
Expand Down
27 changes: 23 additions & 4 deletions test/create-call-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -80,10 +80,18 @@ test('test create-call call-hook basic authentication', async(t) => {
"username": "username",
"password": "password"
},
call_status_hook: {
url: "http://127.0.0.1:3100/callStatus",
method: "POST",
},
"from": from,
"to": {
"type": "phone",
"number": "15583084809"
},
metadata: {
customer: "acme",
referenceId: "deadbeef"
}});

let verbs = [
Expand All @@ -96,13 +104,24 @@ test('test create-call call-hook basic authentication', async(t) => {
//THEN
await p;

let obj = await getJSON(`http:127.0.0.1:3100/lastRequest/${from}`)
t.ok(obj.headers.Authorization = 'Basic dXNlcm5hbWU6cGFzc3dvcmQ=',
'create-call: call-hook contains basic authentication header');
let obj = await getJSON(`http:127.0.0.1:3100/lastRequest/${from}`);
t.ok(
obj.headers.Authorization === "Basic dXNlcm5hbWU6cGFzc3dvcmQ=",
"create-call: call-hook contains basic authentication header"
);
t.ok(
obj.body.customerdata.customer === "acme",
"create-call: metadata is working"
);
obj = await getJSON(`http:127.0.0.1:3100/lastRequest/${from}_callStatus`);
t.ok(
obj.body.customerData.customer === "acme",
"create-call: metadata is working"
);
disconnect();
} catch (err) {
console.log(`error received: ${err}`);
disconnect();
t.error(err);
}
});
});