allow dial to user without supplying sip_realm (will default to that configured for the caller account)

This commit is contained in:
Dave Horton
2020-11-29 15:00:42 -05:00
parent 16c728e246
commit 1bc583e805
4 changed files with 67 additions and 61 deletions

View File

@@ -246,9 +246,10 @@ class TaskDial extends Task {
async _attemptCalls(cs) { async _attemptCalls(cs) {
const {req, srf} = cs; const {req, srf} = cs;
const {getSBC} = srf.locals; const {getSBC} = srf.locals;
const {lookupTeamsByAccount} = srf.locals.dbHelpers; const {lookupTeamsByAccount, lookupAccountBySid} = srf.locals.dbHelpers;
const sbcAddress = this.proxy || getSBC(); const sbcAddress = this.proxy || getSBC();
const teamsInfo = {}; const teamsInfo = {};
let fqdn;
if (!sbcAddress) throw new Error('no SBC found for outbound call'); if (!sbcAddress) throw new Error('no SBC found for outbound call');
const opts = { const opts = {
@@ -270,11 +271,23 @@ class TaskDial extends Task {
this._killOutdials(); this._killOutdials();
}, this.timeout * 1000); }, this.timeout * 1000);
this.target.forEach((t) => { this.target.forEach(async(t) => {
try { try {
t.url = t.url || this.confirmUrl; t.url = t.url || this.confirmUrl;
t.method = t.method || this.confirmMethod || 'POST'; t.method = t.method || this.confirmMethod || 'POST';
if (t.type === 'teams') t.teamsInfo = teamsInfo; if (t.type === 'teams') t.teamsInfo = teamsInfo;
if (t.type === 'user' && !t.name.includes('@') && !fqdn) {
const user = t.name;
try {
const {sip_realm} = await lookupAccountBySid(cs.accountSid);
if (sip_realm) {
t.name = `${user}@${sip_realm}`;
this.logger.debug(`appending sip realm ${sip_realm} to dial target user ${user}`);
}
} catch (err) {
this.logger.error({err}, 'Error looking up account by sid');
}
}
const sd = placeCall({ const sd = placeCall({
logger: this.logger, logger: this.logger,
application: cs.application, application: cs.application,

View File

@@ -103,7 +103,8 @@ function installSrfLocals(srf, logger) {
lookupAppBySid, lookupAppBySid,
lookupAppByRealm, lookupAppByRealm,
lookupAppByTeamsTenant, lookupAppByTeamsTenant,
lookupTeamsByAccount lookupTeamsByAccount,
lookupAccountBySid
} = require('@jambonz/db-helpers')({ } = require('@jambonz/db-helpers')({
host: process.env.JAMBONES_MYSQL_HOST, host: process.env.JAMBONES_MYSQL_HOST,
user: process.env.JAMBONES_MYSQL_USER, user: process.env.JAMBONES_MYSQL_USER,
@@ -142,6 +143,7 @@ function installSrfLocals(srf, logger) {
lookupAppByRealm, lookupAppByRealm,
lookupAppByTeamsTenant, lookupAppByTeamsTenant,
lookupTeamsByAccount, lookupTeamsByAccount,
lookupAccountBySid,
updateCallStatus, updateCallStatus,
retrieveCall, retrieveCall,
listCalls, listCalls,

93
package-lock.json generated
View File

@@ -272,9 +272,9 @@
} }
}, },
"@eslint/eslintrc": { "@eslint/eslintrc": {
"version": "0.1.3", "version": "0.2.1",
"resolved": "https://registry.npmjs.org/@eslint/eslintrc/-/eslintrc-0.1.3.tgz", "resolved": "https://registry.npmjs.org/@eslint/eslintrc/-/eslintrc-0.2.1.tgz",
"integrity": "sha512-4YVwPkANLeNtRjMekzux1ci8hIaH5eGKktGqR0d3LWsKNn5B2X/1Z6Trxy7jQXl9EBGE6Yj02O+t09FMeRllaA==", "integrity": "sha512-XRUeBZ5zBWLYgSANMpThFddrZZkEbGHgUdt5UJjZfnlN9BGCiUBrf+nvbRupSjMvqzwnQN0qwCmOxITt1cfywA==",
"dev": true, "dev": true,
"requires": { "requires": {
"ajv": "^6.12.4", "ajv": "^6.12.4",
@@ -287,14 +287,6 @@
"lodash": "^4.17.19", "lodash": "^4.17.19",
"minimatch": "^3.0.4", "minimatch": "^3.0.4",
"strip-json-comments": "^3.1.1" "strip-json-comments": "^3.1.1"
},
"dependencies": {
"lodash": {
"version": "4.17.20",
"resolved": "https://registry.npmjs.org/lodash/-/lodash-4.17.20.tgz",
"integrity": "sha512-PlhdFcillOINfeV7Ni6oF1TAEayyZBoZ8bcshTHqOYJYlrqzRK5hagpagky5o4HfCzzd1TRkXPMFq6cKk9rGmA==",
"dev": true
}
} }
}, },
"@google-cloud/text-to-speech": { "@google-cloud/text-to-speech": {
@@ -387,8 +379,8 @@
"debug": "^4.1.1", "debug": "^4.1.1",
"fs-extra": "^8.1.0", "fs-extra": "^8.1.0",
"redis": "^2.8.0" "redis": "^2.8.0"
}
}, },
"dependencies": {
"@jambonz/stats-collector": { "@jambonz/stats-collector": {
"version": "0.1.1", "version": "0.1.1",
"resolved": "https://registry.npmjs.org/@jambonz/stats-collector/-/stats-collector-0.1.1.tgz", "resolved": "https://registry.npmjs.org/@jambonz/stats-collector/-/stats-collector-0.1.1.tgz",
@@ -397,6 +389,17 @@
"debug": "^4.2.0", "debug": "^4.2.0",
"hot-shots": "^8.2.0" "hot-shots": "^8.2.0"
} }
}
}
},
"@jambonz/stats-collector": {
"version": "0.1.3",
"resolved": "https://registry.npmjs.org/@jambonz/stats-collector/-/stats-collector-0.1.3.tgz",
"integrity": "sha512-QbxpVXci3up/PjUJazkKEbylrDyqmgx2ekpxDJKlfLmkDTjYwLbmIZONtKrTKhrdZO947orhhVIye5KUxSRTzg==",
"requires": {
"debug": "^4.2.0",
"hot-shots": "^8.2.0"
}
}, },
"@protobufjs/aspromise": { "@protobufjs/aspromise": {
"version": "1.1.2", "version": "1.1.2",
@@ -984,9 +987,9 @@
} }
}, },
"debug": { "debug": {
"version": "4.2.0", "version": "4.3.1",
"resolved": "https://registry.npmjs.org/debug/-/debug-4.2.0.tgz", "resolved": "https://registry.npmjs.org/debug/-/debug-4.3.1.tgz",
"integrity": "sha512-IX2ncY78vDTjZMFUdmsvIRFY2Cf4FnD0wRs+nQwJU8Lu99/tPFdb0VybiiMTPe3I6rQmwsqQqRBvxU+bZ/I8sg==", "integrity": "sha512-doEwdvm4PCeK4K3RQN2ZC2BYUBaxwLARCqZmMjtF8a51J2Rb0xpVloFRnCODwqjpwnAoao4pelN8l3RJdv3gRQ==",
"requires": { "requires": {
"ms": "2.1.2" "ms": "2.1.2"
} }
@@ -1151,9 +1154,9 @@
"integrity": "sha1-Bmlv43Wvt/68AI8oaCJWukEHWAE=" "integrity": "sha1-Bmlv43Wvt/68AI8oaCJWukEHWAE="
}, },
"drachtio-sip": { "drachtio-sip": {
"version": "0.4.1", "version": "0.4.2",
"resolved": "https://registry.npmjs.org/drachtio-sip/-/drachtio-sip-0.4.1.tgz", "resolved": "https://registry.npmjs.org/drachtio-sip/-/drachtio-sip-0.4.2.tgz",
"integrity": "sha512-XjrsVb4O5bjgAr/hWogFk8TLoSp2bbOKYhFAFRayiMs/w7PkYep5z5IOW+erbR8LgVDjZVfdGxjA0RPkI4QMvA==", "integrity": "sha512-2zBR2TcogX2rqlnSdcvCSILOS9JvlvkvI7my4etNjmc+HOI7T8SVcZWErTbQsXBWkZtVo3cpqrfnR8M7UYd2Vw==",
"requires": { "requires": {
"debug": "^4.1.1", "debug": "^4.1.1",
"merge": ">=1.2.1", "merge": ">=1.2.1",
@@ -1163,16 +1166,16 @@
} }
}, },
"drachtio-srf": { "drachtio-srf": {
"version": "4.4.39", "version": "4.4.40",
"resolved": "https://registry.npmjs.org/drachtio-srf/-/drachtio-srf-4.4.39.tgz", "resolved": "https://registry.npmjs.org/drachtio-srf/-/drachtio-srf-4.4.40.tgz",
"integrity": "sha512-wqiCe3nM8C9OJwllYVTMoYpVIjtWgX1TcyYy4y0b8jII9uhyB6CaK8aRfgzesZLJ6NTVlioS3a2Ic3e3Cmrkng==", "integrity": "sha512-j0GrLz/3d3Rvn4qyWO6sJtruWjylz/8yq9TFMlEiTV09SFSOWND5Icu+vpKLVu6xFKKinzrMXk5/np42adITvA==",
"requires": { "requires": {
"async": "^1.4.2", "async": "^1.4.2",
"debug": "^3.2.6", "debug": "^3.2.6",
"delegates": "^0.1.0", "delegates": "^0.1.0",
"deprecate": "^1.1.1", "deprecate": "^1.1.1",
"drachtio-mw-registration-parser": "0.0.2", "drachtio-mw-registration-parser": "0.0.2",
"drachtio-sip": "^0.4.1", "drachtio-sip": "^0.4.2",
"lodash": "^4.17.20", "lodash": "^4.17.20",
"node-noop": "0.0.1", "node-noop": "0.0.1",
"only": "0.0.2", "only": "0.0.2",
@@ -1183,18 +1186,13 @@
}, },
"dependencies": { "dependencies": {
"debug": { "debug": {
"version": "3.2.6", "version": "3.2.7",
"resolved": "https://registry.npmjs.org/debug/-/debug-3.2.6.tgz", "resolved": "https://registry.npmjs.org/debug/-/debug-3.2.7.tgz",
"integrity": "sha512-mel+jf7nrtEl5Pn1Qx46zARXKDpBbvzezse7p7LqINmdoIk8PYP5SySaxEmYv6TZ0JyEKA1hsCId6DIhgITtWQ==", "integrity": "sha512-CFjzYYAi4ThfiQvizrFQevTTXHtnCqWfe7x1AhgEscTz6ZbLbfoLRLPugTQyBth6f8ZERVUSyWHFD/7Wu4t1XQ==",
"requires": { "requires": {
"ms": "^2.1.1" "ms": "^2.1.1"
} }
}, },
"lodash": {
"version": "4.17.20",
"resolved": "https://registry.npmjs.org/lodash/-/lodash-4.17.20.tgz",
"integrity": "sha512-PlhdFcillOINfeV7Ni6oF1TAEayyZBoZ8bcshTHqOYJYlrqzRK5hagpagky5o4HfCzzd1TRkXPMFq6cKk9rGmA=="
},
"uuid": { "uuid": {
"version": "3.4.0", "version": "3.4.0",
"resolved": "https://registry.npmjs.org/uuid/-/uuid-3.4.0.tgz", "resolved": "https://registry.npmjs.org/uuid/-/uuid-3.4.0.tgz",
@@ -1319,13 +1317,13 @@
"dev": true "dev": true
}, },
"eslint": { "eslint": {
"version": "7.11.0", "version": "7.14.0",
"resolved": "https://registry.npmjs.org/eslint/-/eslint-7.11.0.tgz", "resolved": "https://registry.npmjs.org/eslint/-/eslint-7.14.0.tgz",
"integrity": "sha512-G9+qtYVCHaDi1ZuWzBsOWo2wSwd70TXnU6UHA3cTYHp7gCTXZcpggWFoUVAMRarg68qtPoNfFbzPh+VdOgmwmw==", "integrity": "sha512-5YubdnPXrlrYAFCKybPuHIAH++PINe1pmKNc5wQRB9HSbqIK1ywAnntE3Wwua4giKu0bjligf1gLF6qxMGOYRA==",
"dev": true, "dev": true,
"requires": { "requires": {
"@babel/code-frame": "^7.0.0", "@babel/code-frame": "^7.0.0",
"@eslint/eslintrc": "^0.1.3", "@eslint/eslintrc": "^0.2.1",
"ajv": "^6.10.0", "ajv": "^6.10.0",
"chalk": "^4.0.0", "chalk": "^4.0.0",
"cross-spawn": "^7.0.2", "cross-spawn": "^7.0.2",
@@ -1363,12 +1361,6 @@
"v8-compile-cache": "^2.0.3" "v8-compile-cache": "^2.0.3"
}, },
"dependencies": { "dependencies": {
"lodash": {
"version": "4.17.20",
"resolved": "https://registry.npmjs.org/lodash/-/lodash-4.17.20.tgz",
"integrity": "sha512-PlhdFcillOINfeV7Ni6oF1TAEayyZBoZ8bcshTHqOYJYlrqzRK5hagpagky5o4HfCzzd1TRkXPMFq6cKk9rGmA==",
"dev": true
},
"semver": { "semver": {
"version": "7.3.2", "version": "7.3.2",
"resolved": "https://registry.npmjs.org/semver/-/semver-7.3.2.tgz", "resolved": "https://registry.npmjs.org/semver/-/semver-7.3.2.tgz",
@@ -2028,9 +2020,9 @@
"dev": true "dev": true
}, },
"import-fresh": { "import-fresh": {
"version": "3.2.1", "version": "3.2.2",
"resolved": "https://registry.npmjs.org/import-fresh/-/import-fresh-3.2.1.tgz", "resolved": "https://registry.npmjs.org/import-fresh/-/import-fresh-3.2.2.tgz",
"integrity": "sha512-6e1q1cnWP2RXD9/keSkxHScg508CdXqXWgWBaETNhyuBFz+kUZlKboh+ISK+bU++DmbHimVBrOz/zzPe0sZ3sQ==", "integrity": "sha512-cTPNrlvJT6twpYy+YmKUKrTSjWFs3bjYjAhCwm+z4EOCubZxAuO+hHpRN64TqjEaYSHs7tJAE0w1CKMGmsG/lw==",
"dev": true, "dev": true,
"requires": { "requires": {
"parent-module": "^1.0.0", "parent-module": "^1.0.0",
@@ -2447,8 +2439,7 @@
"lodash": { "lodash": {
"version": "4.17.20", "version": "4.17.20",
"resolved": "https://registry.npmjs.org/lodash/-/lodash-4.17.20.tgz", "resolved": "https://registry.npmjs.org/lodash/-/lodash-4.17.20.tgz",
"integrity": "sha512-PlhdFcillOINfeV7Ni6oF1TAEayyZBoZ8bcshTHqOYJYlrqzRK5hagpagky5o4HfCzzd1TRkXPMFq6cKk9rGmA==", "integrity": "sha512-PlhdFcillOINfeV7Ni6oF1TAEayyZBoZ8bcshTHqOYJYlrqzRK5hagpagky5o4HfCzzd1TRkXPMFq6cKk9rGmA=="
"dev": true
}, },
"lodash.camelcase": { "lodash.camelcase": {
"version": "4.3.0", "version": "4.3.0",
@@ -2489,9 +2480,9 @@
"integrity": "sha1-hxDXrwqmJvj/+hzgAWhUUmMlV0g=" "integrity": "sha1-hxDXrwqmJvj/+hzgAWhUUmMlV0g="
}, },
"merge": { "merge": {
"version": "1.2.1", "version": "2.1.0",
"resolved": "https://registry.npmjs.org/merge/-/merge-1.2.1.tgz", "resolved": "https://registry.npmjs.org/merge/-/merge-2.1.0.tgz",
"integrity": "sha512-VjFo4P5Whtj4vsLzsYBu5ayHhoHJ0UqNm7ibvShmbmoz7tGi0vXaoJbGdB+GmDMLUdg8DpQXEIeVDAe8MaABvQ==" "integrity": "sha512-TcuhVDV+e6X457MQAm7xIb19rWhZuEDEho7RrwxMpQ/3GhD5sDlnP188gjQQuweXHy9igdke5oUtVOXX1X8Sxg=="
}, },
"merge-descriptors": { "merge-descriptors": {
"version": "1.0.1", "version": "1.0.1",
@@ -3913,9 +3904,9 @@
"integrity": "sha512-pW0No1RGHgzlpHJO1nsVrHKpOEIxkGg1xB+v0ZmdNH5OAeAwzAVrCnI2/6Mtx+Uys6iaylxa+D3g4j63IKKjSQ==" "integrity": "sha512-pW0No1RGHgzlpHJO1nsVrHKpOEIxkGg1xB+v0ZmdNH5OAeAwzAVrCnI2/6Mtx+Uys6iaylxa+D3g4j63IKKjSQ=="
}, },
"v8-compile-cache": { "v8-compile-cache": {
"version": "2.1.1", "version": "2.2.0",
"resolved": "https://registry.npmjs.org/v8-compile-cache/-/v8-compile-cache-2.1.1.tgz", "resolved": "https://registry.npmjs.org/v8-compile-cache/-/v8-compile-cache-2.2.0.tgz",
"integrity": "sha512-8OQ9CL+VWyt3JStj7HX7/ciTL2V3Rl1Wf5OL+SNTm0yK1KvtReVulksyeRnCANHHuUxHlQig+JJDlUhBt1NQDQ==", "integrity": "sha512-gTpR5XQNKFwOd4clxfnhaqvfqMpqEwr4tOtCyz4MtYZX2JYhfr1JvBFKdS+7K/9rfpZR3VLX+YWBbKoxCgS43Q==",
"dev": true "dev": true
}, },
"vary": { "vary": {

View File

@@ -28,13 +28,13 @@
"dependencies": { "dependencies": {
"@jambonz/db-helpers": "^0.5.1", "@jambonz/db-helpers": "^0.5.1",
"@jambonz/realtimedb-helpers": "^0.2.19", "@jambonz/realtimedb-helpers": "^0.2.19",
"@jambonz/stats-collector": "^0.1.1 ", "@jambonz/stats-collector": "^0.1.3",
"bent": "^7.3.12", "bent": "^7.3.12",
"cidr-matcher": "^2.1.1", "cidr-matcher": "^2.1.1",
"debug": "^4.2.0", "debug": "^4.3.1",
"deepcopy": "^2.1.0", "deepcopy": "^2.1.0",
"drachtio-fsmrf": "^2.0.2", "drachtio-fsmrf": "^2.0.2",
"drachtio-srf": "^4.4.39", "drachtio-srf": "^4.4.40",
"express": "^4.17.1", "express": "^4.17.1",
"ip": "^1.1.5", "ip": "^1.1.5",
"jambonz-mw-registrar": "^0.1.3", "jambonz-mw-registrar": "^0.1.3",
@@ -45,11 +45,11 @@
"xml2js": "^0.4.23" "xml2js": "^0.4.23"
}, },
"devDependencies": { "devDependencies": {
"lodash": "4.17.20",
"blue-tape": "^1.0.0", "blue-tape": "^1.0.0",
"clear-module": "^4.1.1", "clear-module": "^4.1.1",
"eslint": "^7.11.0", "eslint": "^7.14.0",
"eslint-plugin-promise": "^4.2.1", "eslint-plugin-promise": "^4.2.1",
"lodash": "4.17.20",
"nyc": "^15.1.0", "nyc": "^15.1.0",
"tap-dot": "^2.0.0", "tap-dot": "^2.0.0",
"tap-spec": "^5.0.0" "tap-spec": "^5.0.0"