Commit d98766cab44a2f8a49fbe484ae79c23719d9def3
1 parent
81df4efb46
Exists in
master
listtrxall blacklist on some transport
Showing 1 changed file with 20 additions and 4 deletions Side-by-side Diff
lib/command-handler/listtrx.js
1 | 1 | const coreEndpoint = '/histories/trx'; |
2 | 2 | |
3 | +const config = require('komodo-sdk/config'); | |
4 | + | |
3 | 5 | const commandError = require('./error'); |
4 | 6 | const coreapi = require('../coreapi'); |
5 | 7 | |
... | ... | @@ -7,8 +9,24 @@ function help(keyword, commandGroup) { |
7 | 9 | return `Untuk melihat list transaksi${ commandGroup === 'listtrxall' ? ' termasuk downline': ''}, ketik perintah dengan format: ${ keyword.toUpperCase() }.<PIN> atau ${ keyword.toUpperCase() }.<TANGGAL>.<PIN>. Format tanggal YYYY-MM-DD, contoh 2018-12-31 untuk tanggal 31 Desember 2018.`; |
8 | 10 | } |
9 | 11 | |
10 | -function execute(tokens, params, cb) { | |
12 | +module.exports = (tokens, params, cb) => { | |
13 | + if (params.commandGroup === 'listtrxall') { | |
14 | + const blacklisted = ((config.blacklist_help_for_origins || []).indexOf(params.origin || '') >= 0) | |
15 | + || ((config.blacklist_help_for_origin_transports || []).indexOf(params.origin_transport || '') >= 0); | |
16 | + | |
17 | + if (blacklisted) { | |
18 | + const body = `Perintah "${tokens[0]}" tdk tersedia pd jalur SMS dan sejenis.`; | |
19 | + const responseParams = { | |
20 | + body | |
21 | + } | |
22 | + | |
23 | + cb(null, null, responseParams); | |
24 | + return; | |
25 | + } | |
26 | + } | |
11 | 27 | |
28 | + | |
29 | + | |
12 | 30 | if (!tokens || tokens.length < 2) { |
13 | 31 | const responseParams = { |
14 | 32 | body: `${ commandError.ERR_INVALID_FORMAT }. ${ help(tokens[0], params.commandGroup) }` |
... | ... | @@ -33,6 +51,4 @@ function execute(tokens, params, cb) { |
33 | 51 | }; |
34 | 52 | |
35 | 53 | coreapi(coreEndpoint, coreParams, 'GET', cb); |
36 | -} | |
37 | - | |
38 | -module.exports = execute; | |
39 | 54 | \ No newline at end of file |
55 | +}; |