Commit 30b2d328a545161ee38ca60c5e3d9ecc212940cd

Authored by Adhidarma Hadiwinoto
1 parent bf65ed88cf
Exists in master

DEBUG on modem-chooser

Showing 1 changed file with 10 additions and 2 deletions Side-by-side Diff

lib/modem-chooser.js
... ... @@ -5,21 +5,29 @@ const modems = require('./modems2');
5 5 const partnerLastSeen = require('./partner-last-seen');
6 6  
7 7 function filterOutCandidates(candidates) {
  8 + const logger = global.KOMODO_LOGGER;
  9 +
8 10 if (!Array.isArray(candidates)) {
9 11 return [];
10 12 }
11 13  
12 14 if (!candidates.length) return [];
13 15  
14   - return candidates.filter((item) => {
  16 + const filtered = candidates.filter((item) => {
15 17 if (typeof item !== 'string') return false;
16 18 if (item.indexOf('#') >= 0) return false;
17 19  
18 20 const modem = modems.get('imsi', item);
19   - if (!modem) return false;
  21 + if (!modem) {
  22 + if (logger) logger.verbose(`MODEM-CHOOSER: No modem with IMSI ${item} found, removing from candidates`);
  23 + return false;
  24 + }
20 25  
21 26 return true;
22 27 });
  28 +
  29 + if (logger) logger.verbose('MODEM-CHOOSER: Senders candidates reduced', { candidates, filtered });
  30 + return filtered;
23 31 }
24 32  
25 33 exports.chooser = async function chooser(destination, config) {