diff --git a/lib/call-session.js b/lib/call-session.js index 68ac151..bf1e05c 100644 --- a/lib/call-session.js +++ b/lib/call-session.js @@ -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')); } diff --git a/lib/middleware.js b/lib/middleware.js index c3bb458..f139217 100644 --- a/lib/middleware.js +++ b/lib/middleware.js @@ -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 ?