diff --git a/lib/call-session.js b/lib/call-session.js index f16f9da..45851f5 100644 --- a/lib/call-session.js +++ b/lib/call-session.js @@ -124,14 +124,22 @@ class CallSession extends Emitter { }; if (this.req.locals.registration) { - debug(`sending call to user ${JSON.stringify(this.req.locals.registration)}`); + debug(`sending call to registered user ${JSON.stringify(this.req.locals.registration)}`); + let destUri = this.req.uri; + if (this.req.has('X-Override-To')) { + const dest = this.req.get('X-Override-To'); + const uri = parseUri(contact); + uri.user = dest; + destUri = stringifyUri(uri); + this.logger.info(`overriding destination user with ${dest}, so final uri is ${destUri}`); + } const contact = this.req.locals.registration.contact; if (contact.includes('transport=ws')) { uris = [contact]; } else { proxy = this.req.locals.registration.proxy; - uris = [this.req.uri]; + uris = [destUri]; } } else if (this.req.locals.target === 'forward') {