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

@@ -39,6 +39,7 @@ function compareTasks(t1, t2) {
case 'phone':
return t1.number === t1.number;
case 'user':
case 'teams':
return t2.name === t1.name;
case 'sip':
return t2.sipUri === t1.sipUri;
@@ -243,7 +244,9 @@ class TaskDial extends Task {
async _attemptCalls(cs) {
const {req, srf} = cs;
const {getSBC} = srf.locals;
const {lookupTeamsByAccount} = srf.locals.dbHelpers;
const sbcAddress = getSBC();
const teamsInfo = {};
if (!sbcAddress) throw new Error('no SBC found for outbound call');
const opts = {
@@ -252,6 +255,12 @@ class TaskDial extends Task {
callingNumber: this.callerId || req.callingNumber
};
if (this.target.find((t) => t.type === 'teams')) {
const obj = await lookupTeamsByAccount(cs.accountSid);
if (!obj) throw new Error('dial to ms teams not allowed; account must first be configured with teams info');
Object.assign(teamsInfo, {tenant_fqdn: obj.tenant_fqdn, ms_teams_fqdn: obj.ms_teams_fqdn});
}
const ms = await cs.getMS();
const timerRing = setTimeout(() => {
this.logger.info(`Dial:_attemptCall: ring no answer timer ${this.timeout}s exceeded`);
@@ -262,6 +271,7 @@ class TaskDial extends Task {
try {
t.url = t.url || this.confirmUrl;
t.method = t.method || this.confirmMethod || 'POST';
if (t.type === 'teams') t.teamsInfo = teamsInfo;
const sd = placeCall({
logger: this.logger,
application: cs.application,
@@ -393,6 +403,7 @@ class TaskDial extends Task {
_bridgeEarlyMedia(sd) {
if (this.epOther && !this.bridged) {
this.epOther.api('uuid_break', this.epOther.uuid);
this.logger.debug('Dial:_bridgeEarlyMedia: bridging early media');
this.epOther.bridge(sd.ep);
this.bridged = true;
}