Commit f2be872ef8e628fd0e04e9de67eee13492ac1221
1 parent
875440c0e9
Exists in
master
and in
1 other branch
config.terminals_with_location
Showing 2 changed files with 32 additions and 11 deletions Side-by-side Diff
config.sample.json
... | ... | @@ -26,6 +26,8 @@ |
26 | 26 | "max_retry": 10 |
27 | 27 | }, |
28 | 28 | |
29 | + "terminals_with_location": [], | |
30 | + | |
29 | 31 | "# cluster": "Isi dengan boolean atau angka jumlah anak yang akan dibuat. Jika diisi boolean true, jumlah anak akan dihitung otomatis", |
30 | 32 | "cluster": false |
31 | 33 | } |
32 | 34 | \ No newline at end of file |
lib/partner-listener/routers/topup.js
... | ... | @@ -12,6 +12,12 @@ const dumper = require('../dumper'); |
12 | 12 | const router = express.Router(); |
13 | 13 | module.exports = router; |
14 | 14 | |
15 | +const terminalsWithLocation = Array.isArray(config.terminals_with_location) | |
16 | + ? config.terminals_with_location | |
17 | + .filter((item) => typeof item === 'string') | |
18 | + .map((item) => (item.trim().toLowerCase())) | |
19 | + : []; | |
20 | + | |
15 | 21 | function onInvalidParameter(missingParameter, req, res) { |
16 | 22 | logger.verbose(`${MODULE_NAME} 1536D577: Undefined ${missingParameter} parameter`, { |
17 | 23 | xid: res.locals.xid, |
... | ... | @@ -60,22 +66,35 @@ async function pageIndex(req, res) { |
60 | 66 | |
61 | 67 | const terminalName = `${req.body.terminal_name || req.query.terminal_name}@${req.ip.replace(/^::ffff:/, '')}`; |
62 | 68 | |
69 | + const qs = { | |
70 | + terminal_name: terminalName, | |
71 | + password: req.body.password || req.query.password, | |
72 | + request_id: req.body.request_id || req.query.request_id, | |
73 | + product_name: req.body.product_name || req.query.product_name, | |
74 | + destination: req.body.destination || req.query.destination, | |
75 | + origin: config.name || 'HTTPGETX', | |
76 | + report_ip: config.listener.core.ip || null, | |
77 | + report_port: config.listener.core.port, | |
78 | + reverse_url: req.body.reverse_url || req.query.reverse_url || null, | |
79 | + }; | |
80 | + | |
81 | + if (terminalsWithLocation.indexOf(terminalName.toLowerCase()) >= 0) { | |
82 | + const location = req.body.location | |
83 | + || req.body.location_id | |
84 | + || req.query.location | |
85 | + || req.query.location_id; | |
86 | + | |
87 | + if (location) { | |
88 | + qs.location = location; | |
89 | + } | |
90 | + } | |
91 | + | |
63 | 92 | matrix.core.sent += 1; |
64 | 93 | |
65 | 94 | const [err, coreResponse] = await coreapi({ |
66 | 95 | xid, |
67 | 96 | path: '/prepaid/buy', |
68 | - qs: { | |
69 | - terminal_name: terminalName, | |
70 | - password: req.body.password || req.query.password, | |
71 | - request_id: req.body.request_id || req.query.request_id, | |
72 | - product_name: req.body.product_name || req.query.product_name, | |
73 | - destination: req.body.destination || req.query.destination, | |
74 | - origin: config.name || 'HTTPGETX', | |
75 | - report_ip: config.listener.core.ip || null, | |
76 | - report_port: config.listener.core.port, | |
77 | - reverse_url: req.body.reverse_url || req.query.reverse_url || null, | |
78 | - }, | |
97 | + qs, | |
79 | 98 | }); |
80 | 99 | |
81 | 100 | if (err || !coreResponse) { |