add support for ms teams

This commit is contained in:
Dave Horton
2020-05-22 19:17:16 -04:00
parent 1d9658905f
commit c663cbd7b2
7 changed files with 87 additions and 36 deletions

View File

@@ -7,7 +7,7 @@ const parseUri = require('drachtio-srf').parseUri;
const normalizeJambones = require('./utils/normalize-jambones');
module.exports = function(srf, logger) {
const {lookupAppByPhoneNumber, lookupAppBySid, lookupAppByRealm} = srf.locals.dbHelpers;
const {lookupAppByPhoneNumber, lookupAppBySid, lookupAppByRealm, lookupAppByTeamsTenant} = srf.locals.dbHelpers;
function initLocals(req, res, next) {
const callSid = req.has('X-Retain-Call-Sid') ? req.get('X-Retain-Call-Sid') : uuidv4();
@@ -21,6 +21,7 @@ module.exports = function(srf, logger) {
req.locals.application_sid = application_sid;
}
if (req.has('X-Authenticated-User')) req.locals.originatingUser = req.get('X-Authenticated-User');
if (req.has('X-MS-Teams-Tenant-FQDN')) req.locals.msTeamsTenant = req.get('X-MS-Teams-Tenant-FQDN');
next();
}
@@ -64,6 +65,10 @@ module.exports = function(srf, logger) {
}
}
else if (req.locals.msTeamsTenant) {
app = await lookupAppByTeamsTenant(req.locals.msTeamsTenant);
if (app) logger.debug({app}, `retrieved app for ms teams tenant ${req.locals.msTeamsTenant}`);
}
else {
const uri = parseUri(req.uri);
const arr = /context-(.*)/.exec(uri.user);