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

support device call to app #120

Closed
wants to merge 5 commits into from
Closed
Show file tree
Hide file tree
Changes from 1 commit
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
7 changes: 6 additions & 1 deletion lib/call-session.js
Original file line number Diff line number Diff line change
Expand Up @@ -224,6 +224,9 @@ class CallSession extends Emitter {
if (this.req.locals.application_sid) {
Object.assign(headers, {'X-Application-Sid': this.req.locals.application_sid});
}
if (this.req.locals.queue_name) {
Object.assign(headers, {'X-Queue-Name': this.req.locals.queue_name});
}
if (this.req.authorization) {
if (this.req.authorization.grant && this.req.authorization.grant.application_sid) {
Object.assign(headers, {'X-Application-Sid': this.req.authorization.grant.application_sid});
Expand All @@ -248,7 +251,9 @@ class CallSession extends Emitter {
'-Max-Forwards',
'-Record-Route',
'-Session-Expires',
'-X-Subspace-Forwarded-For'
'-X-Subspace-Forwarded-For',
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

let remove this altogether, Subspace no longer exists

'-X-Application-Sid',
'-X-Queue-Name'
],
proxyResponseHeaders: ['all', '-X-Trace-ID'],
localSdpB: spdOfferB,
Expand Down
6 changes: 4 additions & 2 deletions lib/middleware.js
Original file line number Diff line number Diff line change
Expand Up @@ -198,9 +198,10 @@ module.exports = function(srf, logger) {
return req.srf.endSession(req);
}
let deviceAppSid = null;
if (req.has('X-Application-Sid')) {
const queue_name = uri.user.startWith('queue-') ? uri.user.match(/queue-(.*)/)[1] : null;
if (uri.user.startWith('app-')) {
// Call from registered device to test application.
const appSid = req.get('X-Application-Sid');
const appSid = uri.user.match(/app-(.*)/)[1];
const app = await lookupAppBySid(appSid);
if (app && app.account_sid === account.account_sid) {
deviceAppSid = app.application_sid;
Expand All @@ -211,6 +212,7 @@ module.exports = function(srf, logger) {
account_sid: account.account_sid,
account,
application_sid: deviceAppSid || account.device_calling_application_sid,
...(queue_name && ({queue_name})),
webhook_secret: account.webhook_secret,
realm: uri.host,
...(account.registration_hook && {
Expand Down
Loading