Compare View
Commits (3)
Changes
Showing 6 changed files Side-by-side Diff
CHANGELOG.md
... | ... | @@ -4,8 +4,15 @@ All notable changes to this project will be documented in this file. Dates are d |
4 | 4 | |
5 | 5 | Generated by [`auto-changelog`](https://github.com/CookPete/auto-changelog). |
6 | 6 | |
7 | +#### [v0.14.14](https://gitlab.kodesumber.com/komodo/komodo-center-messaging/compare/v0.14.13...v0.14.14) | |
8 | + | |
9 | +- Fix eslint on buy.js [`5c4cf02`](https://gitlab.kodesumber.com/komodo/komodo-center-messaging/commit/5c4cf023bc4bfad2cc0101c57492dd185399c915) | |
10 | +- Add xid on messages-archives.insert [`8d90a39`](https://gitlab.kodesumber.com/komodo/komodo-center-messaging/commit/8d90a3941f5d340bca2ef964ee8497b16e857cf1) | |
11 | + | |
7 | 12 | #### [v0.14.13](https://gitlab.kodesumber.com/komodo/komodo-center-messaging/compare/v0.14.12...v0.14.13) |
8 | 13 | |
14 | +> 4 October 2021 | |
15 | + | |
9 | 16 | - Respon "OK" jika msg kosong pada config.do_not_reply_warning_on_empty_message [`6400063`](https://gitlab.kodesumber.com/komodo/komodo-center-messaging/commit/640006352a87c35c9f0601252fec79c966fac281) |
10 | 17 | |
11 | 18 | #### [v0.14.12](https://gitlab.kodesumber.com/komodo/komodo-center-messaging/compare/v0.14.11...v0.14.12) |
lib/command-handler/buy.js
... | ... | @@ -18,22 +18,22 @@ function generateRequestId(product, destination) { |
18 | 18 | */ |
19 | 19 | |
20 | 20 | function help() { |
21 | - return `Untuk pembelian, ketik perintah dengan format: <KODEPRODUK>.<NOMORTUJUAN>.<PIN>`; | |
21 | + return 'Untuk pembelian, ketik perintah dengan format: <KODEPRODUK>.<NOMORTUJUAN>.<PIN>'; | |
22 | 22 | } |
23 | 23 | |
24 | 24 | function execute(tokens, params, cb) { |
25 | 25 | if (!tokens || tokens.length < 3) { |
26 | 26 | const responseParams = { |
27 | - body: `${ commandError.ERR_INVALID_FORMAT }. ${ help() }` | |
28 | - } | |
27 | + body: `${commandError.ERR_INVALID_FORMAT}. ${help()}`, | |
28 | + }; | |
29 | 29 | |
30 | 30 | cb(null, null, responseParams); |
31 | 31 | return; |
32 | 32 | } |
33 | 33 | |
34 | - if (commands[ tokens[0] ] !== 'buy') { | |
34 | + if (commands[tokens[0]] !== 'buy') { | |
35 | 35 | tokens.unshift('buy'); |
36 | - logger.verbose('Rearrange tokens', {tokens: tokens}); | |
36 | + logger.verbose('Rearrange tokens', { tokens }); | |
37 | 37 | } |
38 | 38 | |
39 | 39 | const destination = destinationCorrector((tokens[2] || '').trim()); |
... | ... | @@ -46,13 +46,12 @@ function execute(tokens, params, cb) { |
46 | 46 | product_name: (tokens[1] || '').trim().toUpperCase(), |
47 | 47 | destination, |
48 | 48 | password: tokens[3], |
49 | - // request_id: `${generateRequestId(tokens[1], destination)}${Number(tokens[4]) ? '_req' + Number(tokens[4]) : ''}`, | |
50 | - request_id_suffix: tokens[4] || '', | |
51 | - postpaid: 0 | |
49 | + request_id_suffix: tokens[4] || '', | |
50 | + postpaid: 0, | |
52 | 51 | }; |
53 | 52 | |
54 | 53 | const coreEndpoint = config.buy_only_prepaid ? coreEndpointBuy : coreEndpointAuto; |
55 | 54 | coreapi(coreEndpoint, coreParams, 'GET', cb); |
56 | 55 | } |
57 | 56 | |
58 | -module.exports = execute; | |
59 | 57 | \ No newline at end of file |
58 | +module.exports = execute; |
lib/http-listener.js
lib/messages-archive.js
... | ... | @@ -20,7 +20,7 @@ if (!redisClient) { |
20 | 20 | } |
21 | 21 | |
22 | 22 | function composeRedisCounterKeyword(origin, direction) { |
23 | - const directionLabel = direction == DIRECTION_OUTGOING ? 'OUT' : 'IN'; | |
23 | + const directionLabel = Number(direction) === DIRECTION_OUTGOING ? 'OUT' : 'IN'; | |
24 | 24 | return `CALMA_MESSAGE_COUNTER_${origin}_${directionLabel}`; |
25 | 25 | } |
26 | 26 | |
... | ... | @@ -34,7 +34,7 @@ function incrementCounter(origin, direction) { |
34 | 34 | |
35 | 35 | /** |
36 | 36 | * Menyimpan pesan ke dalam archive histori pesan di database |
37 | - * | |
37 | + * | |
38 | 38 | * @param {object} params - objek pesan yang akan disimpan |
39 | 39 | * @param {string} [params.origin_label] - label origin |
40 | 40 | * @param {string} [params.origin=UNKNOWN] - digunakan sebagai label origin jika tdk ditentukan |
... | ... | @@ -44,18 +44,18 @@ function incrementCounter(origin, direction) { |
44 | 44 | * @param {string} [params.message] - isi pesan, jika params.msg tidak terdefinisi |
45 | 45 | * @param {number} direction - 0: incoming, 1: outgoing |
46 | 46 | */ |
47 | -function insert(params, direction) { | |
47 | +function insert(xid, params, direction) { | |
48 | 48 | incrementCounter( |
49 | 49 | params.origin_label || params.origin, |
50 | - direction | |
50 | + direction, | |
51 | 51 | ); |
52 | 52 | |
53 | 53 | if (!db.pool) { |
54 | - logger.warn('MESSAGE-ARCHIVE: DB POOL is not ready to insert message history'); | |
54 | + logger.warn('MESSAGE-ARCHIVE: DB POOL is not ready to insert message history', { xid }); | |
55 | 55 | return; |
56 | 56 | } |
57 | 57 | |
58 | - const query = `INSERT INTO messages SET ?`; | |
58 | + const query = 'INSERT INTO messages SET ?'; | |
59 | 59 | const values = [{ |
60 | 60 | origin_label: (params.origin_label || params.origin || 'UNKNOWN').trim(), |
61 | 61 | origin_transport: (params.origin_transport || 'UNKNOWN').trim(), |
... | ... | @@ -67,11 +67,11 @@ function insert(params, direction) { |
67 | 67 | db.pool.query(query, values, async (err) => { |
68 | 68 | if (err) { |
69 | 69 | const fullQuery = await db.format(query, values); |
70 | - logger.warn(`MESSAGES-ARCHIVE: DB ERROR on inserting message. ${err.toString()}`, { query: fullQuery }); | |
70 | + logger.warn(`MESSAGES-ARCHIVE: DB ERROR on inserting message. ${err.toString()}`, { xid, query: fullQuery }); | |
71 | 71 | } |
72 | 72 | }); |
73 | 73 | } |
74 | 74 | |
75 | 75 | exports.insert = insert; |
76 | 76 | exports.DIRECTION_INCOMING = DIRECTION_INCOMING; |
77 | -exports.DIRECTION_OUTGOING = DIRECTION_OUTGOING; | |
78 | 77 | \ No newline at end of file |
78 | +exports.DIRECTION_OUTGOING = DIRECTION_OUTGOING; |
package-lock.json
1 | 1 | { |
2 | 2 | "name": "komodo-center-messaging", |
3 | - "version": "0.14.13", | |
3 | + "version": "0.14.14", | |
4 | 4 | "lockfileVersion": 2, |
5 | 5 | "requires": true, |
6 | 6 | "packages": { |
7 | 7 | "": { |
8 | 8 | "name": "komodo-center-messaging", |
9 | - "version": "0.14.13", | |
9 | + "version": "0.14.14", | |
10 | 10 | "license": "ISC", |
11 | 11 | "dependencies": { |
12 | 12 | "auto-changelog": "^2.3.0", |