Commit 4b2ec8eed6856f253cf2b46cf76c8840056e5666

Authored by Adhidarma Hadiwinoto
1 parent c85566e3af
Exists in master

blacklist help

Showing 4 changed files with 12 additions and 4 deletions Side-by-side Diff

... ... @@ -8,5 +8,7 @@
8 8 "127.0.0.1",
9 9 "::ffff:127.0.0.1",
10 10 "::1"
11   - ]
  11 + ],
  12 + "blacklist_help_for_origins": [],
  13 + "blacklist_help_for_origin_transports": []
12 14 }
13 15 \ No newline at end of file
lib/command-handler/help.js
  1 +const config = require('komodo-sdk/config');
1 2 const logger = require('komodo-sdk/logger');
2 3 const commands = require('../command-group');
3 4  
... ... @@ -27,10 +28,14 @@ const msg = 'Perintah tersedia:\n\n' + cmds2.join(',\n\n');
27 28  
28 29 logger.verbose('Help return message constructed', { count: cmds.length, chars: msg.length, lines: msg.split(/\r\n|\r|\n/).length });
29 30  
30   -module.exports = function(cb) {
  31 +module.exports = function(tokens, params, cb) {
  32 + const blacklisted = ((config.blacklist_help_for_origins || []).indexOf(params.origin || '') >= 0)
  33 + || ((config.blacklist_help_for_origin_transports || []).indexOf(params.origin_transport || '') >= 0)
  34 + ;
31 35  
  36 + const body = blacklisted ? `Perintah "${tokens[0]}" tdk tersedia pd jalur SMS dan sejenis.` : msg;
32 37 const responseParams = {
33   - body: msg
  38 + body
34 39 }
35 40  
36 41 cb(null, null, responseParams);
lib/command-handler/index.js
... ... @@ -93,7 +93,7 @@ function execute(msg, params, cb) {
93 93 handlerSupplierBalances(tokens, params, cb);
94 94 }
95 95 else if (commandGroup === 'help') {
96   - handlerHelp(cb)
  96 + handlerHelp(tokens, params, cb)
97 97 }
98 98 else {
99 99 cb(commandError.ERR_NOT_IMPLEMENTED);
lib/http-listener.js
... ... @@ -97,6 +97,7 @@ function mainHandler(req, res) {
97 97  
98 98 const params = {
99 99 origin: req.body.origin || req.query.origin || 'MESSAGING',
  100 + origin_transport: req.body.origin_transport || req.query.origin_transport,
100 101 report_ip: req.body.report_ip || req.query.report_ip || req.ip,
101 102 report_port: req.body.report_port || req.query.report_port,
102 103 from: req.body.partner || req.query.partner || req.body.from || req.query.from,