Commit f2d51eef9e751eeafa3acb5d0ceb8078db07d537

Authored by Adhidarma Hadiwinoto
1 parent a21e7a161e
Exists in master

Ignore senders with '#'

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

lib/modem-chooser.js
... ... @@ -10,9 +10,11 @@ function filterOutCandidates(candidates) {
10 10 }
11 11  
12 12 return candidates.filter((item) => {
13   - const modem = modems.get('by_imsi', item);
  13 + if (item.indexOf('#') >= 0) return false;
14 14  
  15 + const modem = modems.get('by_imsi', item);
15 16 if (!modem) return false;
  17 +
16 18 return true;
17 19 });
18 20 }
... ... @@ -38,7 +40,7 @@ exports.chooser = async function chooser(destination, config) {
38 40 imsiSenders = filterOutCandidates([ await partnerLastSeen.get(destination) ]);
39 41 if (logger) logger.verbose('Suitable senders by last seen', { destination, prefixName, imsiSenders });
40 42 }
41   -
  43 +
42 44 if (!imsiSenders.length) {
43 45 if (logger) logger.verbose('No suitable sender found', { destination, prefixName });
44 46 return;
... ... @@ -47,6 +49,8 @@ exports.chooser = async function chooser(destination, config) {
47 49 const count = imsiSenders.length;
48 50 const idx = Math.round(Math.random() * (count - 1));
49 51 const imsiChoosed = imsiSenders[idx];
  52 +
50 53 if (logger) logger.verbose(`Choose modem with IMSI ${imsiChoosed}`, { destination, prefixName, imsiSenders });
  54 +
51 55 return imsiChoosed;
52 56 }
53 57 \ No newline at end of file