mirror of
https://github.com/jambonz/sbc-inbound.git
synced 2026-07-04 19:11:47 +00:00
track account level calls if env JAMBONES_TRACK_ACCOUNT_CALLS is set
This commit is contained in:
+2
-2
@@ -256,9 +256,9 @@ class CallSession extends Emitter {
|
||||
await other.destroy();
|
||||
} catch (err) {}
|
||||
this.unsubscribeDTMF(this.logger, this.req.get('Call-ID'), this.rtpEngineOpts.uas.tag);
|
||||
if (process.env.JAMBONES_HOSTING) {
|
||||
if (process.env.JAMBONES_HOSTING || process.env.JAMBONES_TRACK_ACCOUNT_CALLS) {
|
||||
this.decrKey(this.callCountKey)
|
||||
.then((count) => this.logger.debug({key: this.callCountKey},
|
||||
.then((count) => this.logger.info({key: this.callCountKey},
|
||||
`after hangup there are ${count} active calls for this account`))
|
||||
.catch((err) => this.logger.error({err}, 'Error decrementing call count'));
|
||||
}
|
||||
|
||||
+2
-1
@@ -220,7 +220,7 @@ module.exports = function(srf, logger) {
|
||||
};
|
||||
|
||||
const checkLimits = async(req, res, next) => {
|
||||
if (!process.env.JAMBONES_HOSTING) return next(); // skip
|
||||
if (!process.env.JAMBONES_HOSTING && !process.env.JAMBONES_TRACK_ACCOUNT_CALLS) return next(); // skip
|
||||
|
||||
const {incrKey, decrKey} = req.srf.locals.realtimeDbHelpers;
|
||||
const {logger, account_sid} = req.locals;
|
||||
@@ -244,6 +244,7 @@ module.exports = function(srf, logger) {
|
||||
try {
|
||||
/* increment the call count */
|
||||
const calls = await incrKey(key);
|
||||
if (!process.env.JAMBONES_HOSTING) return next();
|
||||
|
||||
/* compare to account's limit, though avoid db hit when call count is low */
|
||||
const minLimit = process.env.MIN_CALL_LIMIT ?
|
||||
|
||||
Reference in New Issue
Block a user