Compare View

switch
from
...
to
 
Commits (8)

Changes

Showing 3 changed files Side-by-side Diff

gateway/advice-push-server.js
... ... @@ -8,8 +8,6 @@ const config = require('../config');
8 8 const logger = require('../logger');
9 9 const matrix = require('../matrix');
10 10  
11   -if (!config || !config.push_server || !!config.push_server.apikey || !config.push_server.advice || !config.push_server.advice.url || !config.push_server.advice.port) return;
12   -
13 11 const app = express();
14 12  
15 13 let partner = null;
... ... @@ -17,13 +15,17 @@ let partner = null;
17 15 function setPartner(_partner) {
18 16 partner = _partner;
19 17  
  18 + if (!config || !config.push_server || !config.push_server.apikey || !config.push_server.advice || !config.push_server.advice.url || !config.push_server.advice.port) {
  19 + return;
  20 + }
  21 +
20 22 app.listen(config.push_server.advice.port, function () {
21 23 logger.info('Advice server listening', {port: config.push_server.advice.port});
22 24 });
23 25 }
24 26  
25 27 function isValidApikey(req, res, next) {
26   - if (req.params.apikey === config.push_server.apikey) {
  28 + if (config.push_server && config.push_server.apikey && (req.params.apikey === config.push_server.apikey)) {
27 29 next();
28 30 }
29 31 else {
... ... @@ -45,16 +47,9 @@ function adviceHandler(req, res, next) {
45 47 return;
46 48 }
47 49  
48   - let task = null;
49   -
50   - try {
51   - task = JSON.parse(coreMessage);
52   - }
53   - catch(e) {
54   - logger.warn('PUSH-ADVICE: Exception on parsing task to advice', {err: e});
55   - }
  50 + let task = req.body;
56 51  
57   - if (!task) {
  52 + if (!task || !task.trx_id || !task.destination || !task.product) {
58 53 logger.warn('PUSH-ADVICE: Invalid task');
59 54 res.end('INVALID_TASK');
60 55 return;
... ... @@ -134,6 +134,8 @@ function report(data) {
134 134 data.misc = {};
135 135 }
136 136  
  137 + logger.verbose('Including advice url on report');
  138 +
137 139 data.misc.advice_url = config.push_server.advice.url;
138 140 }
139 141  
1 1 {
2 2 "name": "komodo-sdk",
3   - "version": "1.17.2",
  3 + "version": "1.18.0",
4 4 "description": "SDK for Komodo",
5 5 "main": "index.js",
6 6 "scripts": {