Commit c622bef69c93c5bcd6ad07a58acac92b62203d0e

Authored by Adhidarma Hadiwinoto
1 parent 27b1c37ad6
Exists in master

Ready to test on nuc

Showing 22 changed files with 431 additions and 34 deletions Side-by-side Diff

... ... @@ -23,13 +23,18 @@ function getConnection() { return db; }
23 23 function initTables() {
24 24 logger.verbose('Preparing database tables');
25 25 db.serialize(function() {
26   - db.run('CREATE TABLE IF NOT EXISTS sms( created TEXT, direction TEXT, imsi TEXT, partner TEXT, msg TEXT )');
  26 + db.run('CREATE TABLE IF NOT EXISTS ussd( created TEXT, created_date TEXT, direction TEXT, imsi TEXT, msg TEXT )');
  27 + db.run('CREATE INDEX IF NOT EXISTS idx_ussd_created ON ussd(created)');
  28 + db.run('CREATE INDEX IF NOT EXISTS idx_ussd_created_date_created ON ussd(created_date, created)');
  29 +
  30 + db.run('CREATE TABLE IF NOT EXISTS sms( created TEXT, created_date TEXT, direction TEXT, imsi TEXT, partner TEXT, msg TEXT )');
27 31 db.run('CREATE INDEX IF NOT EXISTS idx_sms_created ON sms(created)');
  32 + db.run('CREATE INDEX IF NOT EXISTS idx_sms_created_date_created ON sms(created_date, created)');
28 33  
29 34 db.run('CREATE TABLE IF NOT EXISTS pendingtrx ( created TEXT, created_date TEXT, trx_id TEXT, destination TEXT, product TEXT )');
30 35 db.run('CREATE INDEX IF NOT EXISTS idx_pendingtrx_created ON pendingtrx(created)');
31   - db.run('CREATE UNIQUE INDEX IF NOT EXISTS idx_pendingtrx_created_date ON pendingtrx(created_date, destination, product)');
32 36 db.run('CREATE UNIQUE INDEX IF NOT EXISTS idx_pendingtrx_trx_id ON pendingtrx(trx_id)');
  37 + db.run('CREATE INDEX IF NOT EXISTS idx_pendingtrx_created_date ON pendingtrx(created_date, destination, product)');
33 38 })
34 39 }
35 40  
... ... @@ -37,11 +42,12 @@ function cleanup(max_days) {
37 42 logger.info('Doing database cleanup');
38 43  
39 44 if (!max_days) {
40   - max_days = 7;
  45 + max_days = 31;
41 46 }
42 47  
43 48 const oldest = moment().add(-1 * max_days, 'days').format('YYYY-MM-DD');
44 49 db.serialize(function() {
  50 + db.run('DELETE FROM ussd WHERE created < ?', oldest);
45 51 db.run('DELETE FROM sms WHERE created < ?', oldest);
46 52 db.run('DELETE FROM pendingtrx WHERE created_date < ?', oldest);
47 53 db.run('VACUUM');
lib/modem-dashboard/index.js
... ... @@ -0,0 +1,64 @@
  1 +"use strict";
  2 +
  3 +const express = require('express');
  4 +const nunjucks = require('nunjucks');
  5 +
  6 +const config = require('komodo-sdk/config');
  7 +const logger = require('komodo-sdk/logger');
  8 +const matrix = require('komodo-sdk/matrix');
  9 +
  10 +
  11 +const routerSms = require('./router-sms');
  12 +const routerUssd = require('./router-ussd');
  13 +
  14 +const app = express();
  15 +
  16 +app.use(express.static(__dirname + '/public', {maxAge: 24 * 3600 * 1000}));
  17 +
  18 +nunjucks.configure(__dirname + '/views', {
  19 + autoescape: true,
  20 + noCache: true,
  21 + express: app
  22 +});
  23 +
  24 +function modemSignal(req, res, next) {
  25 + const signal_strength = matrix && matrix.modem && matrix.modem.signal_strength ? matrix.modem.signal_strength : 0;
  26 + res.locals.signal_strength = signal_strength;
  27 +
  28 + if (signal_strength < 2 || !signal_strength) {
  29 + res.locals.signal_strength_image = 'signal-0.png';
  30 + res.locals.signal_strength_title = 'No signal';
  31 + }
  32 + else if (signal_strength < 10) {
  33 + res.locals.signal_strength_image = 'signal-1.png';
  34 + res.locals.signal_strength_title = 'Marginal';
  35 + }
  36 + else if (signal_strength < 15) {
  37 + res.locals.signal_strength_image = 'signal-2.png';
  38 + res.locals.signal_strength_title = 'OK';
  39 + }
  40 + else if (signal_strength < 20) {
  41 + res.locals.signal_strength_image = 'signal-3.png';
  42 + res.locals.signal_strength_title = 'Good';
  43 + }
  44 + else {
  45 + res.locals.signal_strength_image = 'signal-4.png';
  46 + res.locals.signal_strength_title = 'Excelent';
  47 + }
  48 +
  49 + next();
  50 +}
  51 +
  52 +app.use(modemSignal);
  53 +
  54 +app.get('/', function(req, res, next) {
  55 + res.redirect('/sms');
  56 +})
  57 +
  58 +app.use('/sms', routerSms);
  59 +app.use('/ussd', routerUssd);
  60 +
  61 +const modem_dashboard_port = (config && config.modem_dashboard && config.modem_dashboard.port) ? config.modem_dashboard.port : 22765;
  62 +app.listen(modem_dashboard_port, function () {
  63 + logger.info('Web control panel started', {listen_port: modem_dashboard_port});
  64 +});
lib/modem-dashboard/public/ie10-viewport-bug-workaround.css
... ... @@ -0,0 +1,13 @@
  1 +/*!
  2 + * IE10 viewport hack for Surface/desktop Windows 8 bug
  3 + * Copyright 2014-2015 Twitter, Inc.
  4 + * Licensed under MIT (https://github.com/twbs/bootstrap/blob/master/LICENSE)
  5 + */
  6 +
  7 +/*
  8 + * See the Getting Started docs for more information:
  9 + * http://getbootstrap.com/getting-started/#support-ie10-width
  10 + */
  11 +@-ms-viewport { width: device-width; }
  12 +@-o-viewport { width: device-width; }
  13 +@viewport { width: device-width; }
lib/modem-dashboard/public/ie10-viewport-bug-workaround.js
... ... @@ -0,0 +1,23 @@
  1 +/*!
  2 + * IE10 viewport hack for Surface/desktop Windows 8 bug
  3 + * Copyright 2014-2015 Twitter, Inc.
  4 + * Licensed under MIT (https://github.com/twbs/bootstrap/blob/master/LICENSE)
  5 + */
  6 +
  7 +// See the Getting Started docs for more information:
  8 +// http://getbootstrap.com/getting-started/#support-ie10-width
  9 +
  10 +(function () {
  11 + 'use strict';
  12 +
  13 + if (navigator.userAgent.match(/IEMobile\/10\.0/)) {
  14 + var msViewportStyle = document.createElement('style')
  15 + msViewportStyle.appendChild(
  16 + document.createTextNode(
  17 + '@-ms-viewport{width:auto!important}'
  18 + )
  19 + )
  20 + document.querySelector('head').appendChild(msViewportStyle)
  21 + }
  22 +
  23 +})();
lib/modem-dashboard/public/img/signal-0.png

953 Bytes

lib/modem-dashboard/public/img/signal-1.png

946 Bytes

lib/modem-dashboard/public/img/signal-2.png

924 Bytes

lib/modem-dashboard/public/img/signal-3.png

910 Bytes

lib/modem-dashboard/public/img/signal-4.png

889 Bytes

lib/modem-dashboard/public/starter-template.css
... ... @@ -0,0 +1,7 @@
  1 +body {
  2 + padding-top: 50px;
  3 +}
  4 +.starter-template {
  5 + padding: 40px 15px;
  6 + /* text-align: center; */
  7 +}
lib/modem-dashboard/router-sms.js
... ... @@ -0,0 +1,35 @@
  1 +"use strict";
  2 +
  3 +const moment = require('moment');
  4 +const express = require('express');
  5 +
  6 +const localDb = require('../local-db');
  7 +
  8 +const router = express.Router();
  9 +module.exports = router;
  10 +
  11 +function pageSmsIndex(req, res, next) {
  12 + res.render(
  13 + 'sms.index.html',
  14 + {
  15 + page_title: 'Histori SMS'
  16 + }
  17 + )
  18 +}
  19 +
  20 +function pageSmsDataTables(req, res, next) {
  21 + const db = localDb.getConnection();
  22 +
  23 + const created_date = moment().format('YYYY-MM-DD');
  24 + const query = "SELECT rowid, * FROM sms WHERE created_date = ? ORDER BY created DESC, rowid DESC";
  25 + db.all(query, created_date, function (err, rows) {
  26 + if (err) {
  27 + res.end("Ada error: " + err);
  28 + return;
  29 + }
  30 + res.json({data: rows});
  31 + });
  32 +}
  33 +
  34 +router.get('/', pageSmsIndex);
  35 +router.get('/datatables', pageSmsDataTables);
lib/modem-dashboard/router-ussd.js
... ... @@ -0,0 +1,35 @@
  1 +"use strict";
  2 +
  3 +const moment = require('moment');
  4 +const express = require('express');
  5 +
  6 +const localDb = require('../local-db');
  7 +
  8 +const router = express.Router();
  9 +module.exports = router;
  10 +
  11 +function pageIndex(req, res, next) {
  12 + res.render(
  13 + 'ussd.index.html',
  14 + {
  15 + page_title: 'Histori USSD'
  16 + }
  17 + )
  18 +}
  19 +
  20 +function pageDataTables(req, res, next) {
  21 + const db = localDb.getConnection();
  22 +
  23 + const created_date = moment().format('YYYY-MM-DD');
  24 + const query = "SELECT rowid, * FROM ussd WHERE created_date = ? ORDER BY created DESC, rowid DESC";
  25 + db.all(query, created_date, function (err, rows) {
  26 + if (err) {
  27 + res.end("Ada error: " + err);
  28 + return;
  29 + }
  30 + res.json({data: rows});
  31 + });
  32 +}
  33 +
  34 +router.get('/', pageIndex);
  35 +router.get('/datatables', pageDataTables);
lib/modem-dashboard/views/sms.index.html
... ... @@ -0,0 +1,55 @@
  1 +{% extends "template.html" %}
  2 +
  3 +{% block head %}
  4 +<link rel="stylesheet" type="text/css" href="https://cdn.datatables.net/1.10.18/css/dataTables.bootstrap.min.css">
  5 +<script type="text/javascript" charset="utf8" src="https://cdn.datatables.net/1.10.19/js/jquery.dataTables.js"></script>
  6 +<script type="text/javascript" src="https://cdn.datatables.net/1.10.18/js/dataTables.bootstrap.min.js"></script>
  7 +{% endblock %}
  8 +
  9 +{% block content %}
  10 +
  11 +<table id="smsHistory" class="display table table-hover table-striped">
  12 + <thead>
  13 + <tr>
  14 + <th>#</th>
  15 + <th>Tanggal</th>
  16 + <th>Arah</th>
  17 + <th>IMSI Modem</th>
  18 + <th>Dari/Ke</th>
  19 + <th>Pesan</th>
  20 + </tr>
  21 + </thead>
  22 + <tfoot>
  23 + <tr>
  24 + <th>#</th>
  25 + <th>Tanggal</th>
  26 + <th>Arah</th>
  27 + <th>IMSI Modem</th>
  28 + <th>Dari / Ke</th>
  29 + <th>Pesan</th>
  30 + </tr>
  31 + </tfoot>
  32 +</table>
  33 +
  34 +<script>
  35 + $(document).ready(function() {
  36 + $('#smsHistory').DataTable( {
  37 + "ajax": "/sms/datatables",
  38 + "language": { "url": "//cdn.datatables.net/plug-ins/9dcbecd42ad/i18n/Indonesian.json" },
  39 + "columns": [
  40 + { "data": "rowid" },
  41 + { "data": "created" },
  42 + { "data": "direction" },
  43 + { "data": "imsi" },
  44 + { "data": "partner" },
  45 + { "data": "msg" }
  46 + ],
  47 + "order": [
  48 + [1, "desc"]
  49 + ],
  50 + "lengthMenu": [[50, 100, 200, -1], [50, 100, 200, "All"]]
  51 + } );
  52 + } );
  53 +</script>
  54 +
  55 +{% endblock %}
lib/modem-dashboard/views/template.html
... ... @@ -0,0 +1,102 @@
  1 +<!DOCTYPE html>
  2 +<html lang="en">
  3 + <head>
  4 + <meta charset="utf-8">
  5 + <meta http-equiv="X-UA-Compatible" content="IE=edge">
  6 + <meta name="viewport" content="width=device-width, initial-scale=1">
  7 + <!-- The above 3 meta tags *must* come first in the head; any other head content must come *after* these tags -->
  8 +
  9 + <meta name="description" content="">
  10 + <meta name="author" content="">
  11 + <link rel="icon" href="/favicon.ico">
  12 +
  13 + <title>
  14 + {% if page_title %}
  15 + {{ page_title }}
  16 + -
  17 + {% endif %}
  18 + Modem Dashboard
  19 + </title>
  20 +
  21 + <!-- Latest compiled and minified CSS -->
  22 + <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" integrity="sha384-BVYiiSIFeK1dGmJRAkycuHAHRg32OmUcww7on3RYdg4Va+PmSTsz/K68vbdEjh4u" crossorigin="anonymous">
  23 +
  24 + <!-- Optional theme -->
  25 + <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap-theme.min.css" integrity="sha384-rHyoN1iRsVXV4nD0JutlnGaslCJuC7uwjduW9SVrLvRYooPp2bWYgmgJQIXwl/Sp" crossorigin="anonymous">
  26 +
  27 +
  28 +
  29 + <!-- IE10 viewport hack for Surface/desktop Windows 8 bug -->
  30 + <link href="/ie10-viewport-bug-workaround.css" rel="stylesheet">
  31 +
  32 + <!-- Custom styles for this template -->
  33 + <link href="starter-template.css" rel="stylesheet">
  34 +
  35 + <!-- HTML5 shim and Respond.js for IE8 support of HTML5 elements and media queries -->
  36 + <!--[if lt IE 9]>
  37 + <script src="https://oss.maxcdn.com/html5shiv/3.7.3/html5shiv.min.js"></script>
  38 + <script src="https://oss.maxcdn.com/respond/1.4.2/respond.min.js"></script>
  39 + <![endif]-->
  40 +
  41 + <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.12.4/jquery.min.js"></script>
  42 +
  43 + {% block head %}
  44 + {% endblock %}
  45 + </head>
  46 +
  47 + <body>
  48 +
  49 + <nav class="navbar navbar-inverse navbar-fixed-top">
  50 + <div class="container">
  51 + <div class="navbar-header">
  52 + <button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#navbar" aria-expanded="false" aria-controls="navbar">
  53 + <span class="sr-only">Toggle navigation</span>
  54 + <span class="icon-bar"></span>
  55 + <span class="icon-bar"></span>
  56 + <span class="icon-bar"></span>
  57 + </button>
  58 + <a class="navbar-brand" href="/">Modem Dashboard</a>
  59 + </div>
  60 + <div id="navbar" class="collapse navbar-collapse">
  61 + <ul class="nav navbar-nav">
  62 + <li><a href="/sms">SMS</a></li>
  63 + <li><a href="/ussd">USSD</a></li>
  64 + </ul>
  65 + </div><!--/.nav-collapse -->
  66 + </div>
  67 + </nav>
  68 +
  69 + <div class="container">
  70 +
  71 + <div class="starter-template">
  72 +
  73 + <div style="text-align: right;">
  74 + <img src="/img/{{ signal_strength_image }}" alt="Signal: {{ signal_strength_title }}" title="Signal: {{ signal_strength_title }} ({{ signal_strength }})">
  75 + </div>
  76 +
  77 + {% if page_title%}
  78 + <h1> {{ page_title }} </h1>
  79 + {% endif %}
  80 +
  81 + {% block content %}
  82 +
  83 + &nbsp;
  84 +
  85 + {% endblock %}
  86 +
  87 + </div>
  88 +
  89 + </div><!-- /.container -->
  90 +
  91 +
  92 + <!-- Bootstrap core JavaScript
  93 + ================================================== -->
  94 + <!-- Placed at the end of the document so the pages load faster -->
  95 + <script>window.jQuery || document.write('<script src="../../assets/js/vendor/jquery.min.js"><\/script>')</script>
  96 + <!-- Latest compiled and minified JavaScript -->
  97 + <script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js" integrity="sha384-Tc5IQib027qvyjSMfHjOMaLkfuWVxZxUPnCJA7l2mCWNIpG9mGCD8wGNIcPD7Txa" crossorigin="anonymous"></script>
  98 +
  99 + <!-- IE10 viewport hack for Surface/desktop Windows 8 bug -->
  100 + <script src="/ie10-viewport-bug-workaround.js"></script>
  101 + </body>
  102 +</html>
lib/modem-dashboard/views/ussd.index.html
... ... @@ -0,0 +1,52 @@
  1 +{% extends "template.html" %}
  2 +
  3 +{% block head %}
  4 +<link rel="stylesheet" type="text/css" href="https://cdn.datatables.net/1.10.18/css/dataTables.bootstrap.min.css">
  5 +<script type="text/javascript" charset="utf8" src="https://cdn.datatables.net/1.10.19/js/jquery.dataTables.js"></script>
  6 +<script type="text/javascript" src="https://cdn.datatables.net/1.10.18/js/dataTables.bootstrap.min.js"></script>
  7 +{% endblock %}
  8 +
  9 +{% block content %}
  10 +
  11 +<table id="smsHistory" class="display table table-hover table-striped">
  12 + <thead>
  13 + <tr>
  14 + <th>#</th>
  15 + <th>Tanggal</th>
  16 + <th>Arah</th>
  17 + <th>IMSI Modem</th>
  18 + <th>Pesan</th>
  19 + </tr>
  20 + </thead>
  21 + <tfoot>
  22 + <tr>
  23 + <th>#</th>
  24 + <th>Tanggal</th>
  25 + <th>Arah</th>
  26 + <th>IMSI Modem</th>
  27 + <th>Pesan</th>
  28 + </tr>
  29 + </tfoot>
  30 +</table>
  31 +
  32 +<script>
  33 + $(document).ready(function() {
  34 + $('#smsHistory').DataTable( {
  35 + "ajax": "/ussd/datatables",
  36 + "language": { "url": "//cdn.datatables.net/plug-ins/9dcbecd42ad/i18n/Indonesian.json" },
  37 + "columns": [
  38 + { "data": "rowid" },
  39 + { "data": "created" },
  40 + { "data": "direction" },
  41 + { "data": "imsi" },
  42 + { "data": "msg" }
  43 + ],
  44 + "order": [
  45 + [1, "desc"]
  46 + ],
  47 + "lengthMenu": [[50, 100, 200, -1], [50, 100, 200, "All"]]
  48 + } );
  49 + } );
  50 +</script>
  51 +
  52 +{% endblock %}
... ... @@ -43,7 +43,7 @@ class Modem extends EventEmitter {
43 43 });
44 44  
45 45 this.port.on('open', function() {
46   - self.disableEcho(function() {
  46 + self.resetModem(function() {
47 47 self.getIMSI(function() {
48 48 self.emit('open');
49 49 self.getSignalStrength(cb);
... ... @@ -145,7 +145,7 @@ class Modem extends EventEmitter {
145 145 this.emit('incoming sms', sms);
146 146 }
147 147  
148   - disableEcho(cb) {
  148 + resetModem(cb) {
149 149 const self = this;
150 150  
151 151 if (this.parser) { this.port.unpipe(this.parser)};
... ... @@ -154,7 +154,7 @@ class Modem extends EventEmitter {
154 154 parser.on('data', function(data) {
155 155 const value = data.toString().replace(/^\s+/, '').replace(/\s+$/, '');
156 156  
157   - debugLog('PARSER-DISABLEECHO: echo disabled');
  157 + debugLog('PARSER-RESETMODEM: modem reseted');
158 158  
159 159 self.port.unpipe(parser);
160 160 self.resetParserToDefault();
... ... @@ -164,7 +164,7 @@ class Modem extends EventEmitter {
164 164 }
165 165 })
166 166  
167   - this.write('ATE0\r');
  167 + this.write('AT &F Z E0\r');
168 168 }
169 169  
170 170 getIMSI(cb) {
lib/partner-mkios.js
1 1 "use strict";
2 2  
  3 +const moment = require('moment');
  4 +
3 5 const Modem = require('./modem');
4 6  
5 7 const pullgw = require('komodo-sdk/gateway/pull');
... ... @@ -8,6 +10,8 @@ const config = require(&#39;komodo-sdk/config&#39;);
8 10 const logger = require('komodo-sdk/logger');
9 11 const matrix = require('komodo-sdk/matrix');
10 12  
  13 +const modemDashboard = require('./modem-dashboard');
  14 +
11 15 matrix.modem = {};
12 16 matrix.not_ready = true;
13 17 matrix.stock = {};
... ... @@ -36,9 +40,9 @@ modem.on(&#39;imsi&#39;, function(imsi) {
36 40  
37 41 function onIncomingSMS(sms) {
38 42 logger.info('Incoming SMS', {sms: sms});
39   - db.run("INSERT INTO sms VALUES (?, 'IN', ?, ?, ?)", sms.created, matrix.modem.imsi, sms.sender, sms.msg, function(err) {
  43 + db.run("INSERT INTO sms VALUES (?, ?, 'IN', ?, ?, ?)", sms.created, moment(sms.created).format('YYYY-MM-DD'), matrix.modem.imsi, sms.sender, sms.msg, function(err) {
40 44 if (err) {
41   - logger.warn('Error inserting sms to local database');
  45 + logger.warn('Error inserting sms to local database', {err: err});
42 46 }
43 47 });
44 48  
... ... @@ -105,9 +109,16 @@ modem.on(&#39;signal strength&#39;, function(signal_strength) {
105 109 logger.verbose('Signal strength: ' + signal_strength);
106 110 })
107 111  
108   -modem.on('ussd response', function(data) {
  112 +function onUSSDResponse(data) {
109 113 logger.verbose('Got USSD response', {response: data});
110 114  
  115 + db.run("INSERT INTO ussd VALUES (?, ?, 'IN', ?, ?)", moment().format('YYYY-MM-DD HH:mm:ss'), moment().format('YYYY-MM-DD'), matrix.modem.imsi, data, function(err) {
  116 + if (err) {
  117 + logger.warn('Error inserting ussd response to local database', {err: err});
  118 + }
  119 + });
  120 +
  121 +
111 122 if (!last_trx_id) return;
112 123  
113 124  
... ... @@ -128,7 +139,9 @@ modem.on(&#39;ussd response&#39;, function(data) {
128 139  
129 140 updateStock(stock_name, stock_balance);
130 141 last_trx_id = null;
131   -})
  142 +}
  143 +
  144 +modem.on('ussd response', onUSSDResponse);
132 145  
133 146  
134 147 logger.info('Opening MODEM');
... ... @@ -212,7 +225,7 @@ function suspendPull(trx_id) {
212 225 rc: '68',
213 226 message: 'USSD timeout'
214 227 })
215   - }, Number(config.partner.modem.suspend_time_ms) || 30000)
  228 + }, Number(config.partner.modem.suspend_time_ms) || 20 * 1000 )
216 229 }
217 230  
218 231 function deleteResumeHandler(trx_id) {
... ... @@ -249,6 +262,11 @@ function buy(task) {
249 262 const ussd_command = task.remote_product.split(',')[0].replace("<DESTINATION>", task.destination).replace("<PIN>", config.partner.pin);
250 263 logger.verbose('Going to execute USSD', {trx_id: task.trx_id, destination: task.destination, product: task.product, ussd: ussd_command});
251 264  
  265 + db.run("INSERT INTO ussd VALUES (?, ?, 'OUT', ?, ?)", moment().format('YYYY-MM-DD HH:mm:ss'), moment().format('YYYY-MM-DD'), matrix.modem.imsi, 'AT+CUSD=1,"' + ussd_command + '",15', function(err) {
  266 + if (err) {
  267 + logger.warn('Error inserting ussd command to local database', {err: err});
  268 + }
  269 + });
252 270 modem.sendUSSD(ussd_command, function() {});
253 271 })
254 272  
lib/pending-archive.js
... ... @@ -49,7 +49,7 @@ function get(destination, product, created_date, cb) {
49 49 logger.verbose('PENDING-ARCHIVE: Trying to get trx from table', {destination: destination, product: product, created_date: created_date});
50 50  
51 51  
52   - const query = "SELECT trx_id FROM pendingtrx WHERE created_date = ? AND destination = ? AND product = ? ";
  52 + const query = "SELECT trx_id FROM pendingtrx WHERE created_date = ? AND destination = ? AND product = ? ORDER BY created DESC LIMIT 1";
53 53 db.get(query, created_date, destination, product, function (err, row) {
54 54 if (err) {
55 55 logger.warn('PENDING-ARCHIVE: Error retrieving', {destination: destination, product: product, created_date: created_date, err: err});
... ... @@ -14,7 +14,7 @@ function isAllowedSender(sender) {
14 14 function getDestination(msg) {
15 15 const result = patternMatcher(msg, config.sms_parser.destination);
16 16 if (result && typeof result === 'string') {
17   - return result.replace(/^62/, '0');
  17 + return result.replace(/^62/, '0').replace(/^8/, '08');
18 18 }
19 19 }
20 20  
... ... @@ -1267,11 +1267,6 @@
1267 1267 "version": "5.1.1",
1268 1268 "resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.1.1.tgz",
1269 1269 "integrity": "sha512-kKvNJn6Mm93gAczWVJg7wH+wGYWNrDHdWvpUmHyEsgCtIwwo3bqPtV4tR5tuPaUhTOo/kvhVwd8XwwOllGYkbg=="
1270   - },
1271   - "statuses": {
1272   - "version": "1.4.0",
1273   - "resolved": "https://registry.npmjs.org/statuses/-/statuses-1.4.0.tgz",
1274   - "integrity": "sha512-zhSCtt8v2NDrRlPQpCNtw/heZLtfUDqxBM1udqikb/Hbk52LK4nQSwr10u77iopCW5LsyHpuXS0GnEc48mLeew=="
1275 1270 }
1276 1271 }
1277 1272 },
... ... @@ -1392,11 +1387,6 @@
1392 1387 "requires": {
1393 1388 "ms": "2.0.0"
1394 1389 }
1395   - },
1396   - "statuses": {
1397   - "version": "1.4.0",
1398   - "resolved": "https://registry.npmjs.org/statuses/-/statuses-1.4.0.tgz",
1399   - "integrity": "sha512-zhSCtt8v2NDrRlPQpCNtw/heZLtfUDqxBM1udqikb/Hbk52LK4nQSwr10u77iopCW5LsyHpuXS0GnEc48mLeew=="
1400 1390 }
1401 1391 }
1402 1392 },
... ... @@ -2081,7 +2071,7 @@
2081 2071 "depd": "1.1.2",
2082 2072 "inherits": "2.0.3",
2083 2073 "setprototypeof": "1.1.0",
2084   - "statuses": "1.5.0"
  2074 + "statuses": "1.4.0"
2085 2075 }
2086 2076 },
2087 2077 "http-signature": {
... ... @@ -3540,11 +3530,6 @@
3540 3530 "requires": {
3541 3531 "ms": "2.0.0"
3542 3532 }
3543   - },
3544   - "statuses": {
3545   - "version": "1.4.0",
3546   - "resolved": "https://registry.npmjs.org/statuses/-/statuses-1.4.0.tgz",
3547   - "integrity": "sha512-zhSCtt8v2NDrRlPQpCNtw/heZLtfUDqxBM1udqikb/Hbk52LK4nQSwr10u77iopCW5LsyHpuXS0GnEc48mLeew=="
3548 3533 }
3549 3534 }
3550 3535 },
... ... @@ -4020,9 +4005,9 @@
4020 4005 }
4021 4006 },
4022 4007 "statuses": {
4023   - "version": "1.5.0",
4024   - "resolved": "https://registry.npmjs.org/statuses/-/statuses-1.5.0.tgz",
4025   - "integrity": "sha1-Fhx9rBd2Wf2YEfQ3cfqZOBR4Yow="
  4008 + "version": "1.4.0",
  4009 + "resolved": "https://registry.npmjs.org/statuses/-/statuses-1.4.0.tgz",
  4010 + "integrity": "sha512-zhSCtt8v2NDrRlPQpCNtw/heZLtfUDqxBM1udqikb/Hbk52LK4nQSwr10u77iopCW5LsyHpuXS0GnEc48mLeew=="
4026 4011 },
4027 4012 "strftime": {
4028 4013 "version": "0.10.0",
... ... @@ -23,9 +23,11 @@
23 23 "license": "SEE LICENSE IN LICENSE.txt",
24 24 "dependencies": {
25 25 "cron": "^1.3.0",
  26 + "express": "^4.16.3",
26 27 "jsesc": "^2.5.1",
27 28 "komodo-sdk": "git+http://gitlab.kodesumber.com/komodo/komodo-sdk.git",
28 29 "moment": "^2.22.2",
  30 + "nunjucks": "^3.1.3",
29 31 "serialport": "^6.2.2",
30 32 "sqlite3": "^4.0.2"
31 33 },
1   -28464
2 1 \ No newline at end of file
  2 +6300
3 3 \ No newline at end of file