zalo-toolkit 1.1.7 → 1.1.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/apis/listen.js +20 -18
- package/dist/cjs/apis/listen.cjs +20 -18
- package/package.json +1 -1
package/dist/apis/listen.js
CHANGED
|
@@ -210,9 +210,9 @@ export class Listener extends EventEmitter {
|
|
|
210
210
|
}
|
|
211
211
|
const lastMsg = last(msgs);
|
|
212
212
|
const timestamp = lastMsg ? Number(lastMsg.ts) : Date.now();
|
|
213
|
-
this.onUndoMessageCallback(listUndo);
|
|
214
|
-
this.onMessageCallback(listMessages);
|
|
215
|
-
this.onUpdateQueueStatusCallback(queueStatus, timestamp);
|
|
213
|
+
await this.onUndoMessageCallback(listUndo);
|
|
214
|
+
await this.onMessageCallback(listMessages);
|
|
215
|
+
await this.onUpdateQueueStatusCallback(queueStatus, timestamp);
|
|
216
216
|
}
|
|
217
217
|
if (version == 1 && cmd == 521) {
|
|
218
218
|
const parsedData = (await decodeEventData(parsed, this.cipherKey)).data;
|
|
@@ -237,9 +237,9 @@ export class Listener extends EventEmitter {
|
|
|
237
237
|
}
|
|
238
238
|
const lastMsg = last(groupMsgs);
|
|
239
239
|
const timestamp = lastMsg ? Number(lastMsg.ts) : Date.now();
|
|
240
|
-
this.onUndoMessageCallback(listUndo);
|
|
241
|
-
this.onMessageCallback(listMessages);
|
|
242
|
-
this.onUpdateQueueStatusCallback(queueStatus, timestamp);
|
|
240
|
+
await this.onUndoMessageCallback(listUndo);
|
|
241
|
+
await this.onMessageCallback(listMessages);
|
|
242
|
+
await this.onUpdateQueueStatusCallback(queueStatus, timestamp);
|
|
243
243
|
}
|
|
244
244
|
if ([510, 511, 610, 611, 603, 604].includes(cmd)) {
|
|
245
245
|
const parsedData = (await decodeEventData(parsed, this.cipherKey)).data;
|
|
@@ -342,8 +342,8 @@ export class Listener extends EventEmitter {
|
|
|
342
342
|
}
|
|
343
343
|
const lastMsg = reacts.length > 0 ? last(reacts) : reactGroups.length > 0 ? last(reactGroups) : null;
|
|
344
344
|
const timestamp = lastMsg ? Number(lastMsg.ts) : Date.now();
|
|
345
|
-
this.onReactionCallback(listReactions);
|
|
346
|
-
this.onUpdateQueueStatusCallback(queueStatus, timestamp);
|
|
345
|
+
await this.onReactionCallback(listReactions);
|
|
346
|
+
await this.onUpdateQueueStatusCallback(queueStatus, timestamp);
|
|
347
347
|
}
|
|
348
348
|
if (cmd == 510) {
|
|
349
349
|
const parsedData = (await decodeEventData(parsed, this.cipherKey)).data;
|
|
@@ -362,9 +362,9 @@ export class Listener extends EventEmitter {
|
|
|
362
362
|
});
|
|
363
363
|
const lastMsg = last(msgs);
|
|
364
364
|
const timestamp = lastMsg ? Number(lastMsg.ts) : Date.now();
|
|
365
|
-
this.
|
|
366
|
-
this.onOldMessageCallback(responseMsgs);
|
|
367
|
-
this.
|
|
365
|
+
await this.onUndoMessageCallback(responseUndos);
|
|
366
|
+
await this.onOldMessageCallback(responseMsgs);
|
|
367
|
+
await this.onUpdateQueueStatusCallback(queueStatus, timestamp);
|
|
368
368
|
this.emit('old_messages', responseMsgs);
|
|
369
369
|
}
|
|
370
370
|
if (cmd == 511) {
|
|
@@ -384,9 +384,9 @@ export class Listener extends EventEmitter {
|
|
|
384
384
|
}
|
|
385
385
|
const lastMsg = last(groupMsgs);
|
|
386
386
|
const timestamp = lastMsg ? Number(lastMsg.ts) : Date.now();
|
|
387
|
-
this.
|
|
388
|
-
this.onOldMessageCallback(responseMsgs);
|
|
389
|
-
this.
|
|
387
|
+
await this.onUndoMessageCallback(responseUndos);
|
|
388
|
+
await this.onOldMessageCallback(responseMsgs);
|
|
389
|
+
await this.onUpdateQueueStatusCallback(queueStatus, timestamp);
|
|
390
390
|
this.emit('old_messages', responseMsgs);
|
|
391
391
|
}
|
|
392
392
|
if (cmd == 518) {
|
|
@@ -397,8 +397,8 @@ export class Listener extends EventEmitter {
|
|
|
397
397
|
const listMessage = [...parseMsgs, ...parseGroupMsgs];
|
|
398
398
|
const lastMsg = last(listMessage);
|
|
399
399
|
const timestamp = lastMsg ? Number(lastMsg.ts) : Date.now();
|
|
400
|
-
this.
|
|
401
|
-
this.
|
|
400
|
+
await this.onOldMessageCallback(listMessage);
|
|
401
|
+
await this.onUpdateQueueStatusCallback(queueStatus, timestamp);
|
|
402
402
|
this.emit('old_messages', listMessage);
|
|
403
403
|
}
|
|
404
404
|
if (cmd == 602 && subCmd == 0) {
|
|
@@ -656,9 +656,11 @@ export class Listener extends EventEmitter {
|
|
|
656
656
|
const retryConfig = this.retries[errorCode];
|
|
657
657
|
if (retryConfig) {
|
|
658
658
|
let { times, count, max } = retryConfig;
|
|
659
|
-
if (max != null && count >= max) {
|
|
659
|
+
// if (max != null && count >= max) {
|
|
660
|
+
// return null;
|
|
661
|
+
// }
|
|
662
|
+
if (count >= 3)
|
|
660
663
|
return null;
|
|
661
|
-
}
|
|
662
664
|
this.retries[errorCode].count = ((_a = this.retries[errorCode].count) !== null && _a !== void 0 ? _a : 0) + 1;
|
|
663
665
|
if (typeof times === 'number') {
|
|
664
666
|
return times;
|
package/dist/cjs/apis/listen.cjs
CHANGED
|
@@ -213,9 +213,9 @@ class Listener extends stream.EventEmitter {
|
|
|
213
213
|
}
|
|
214
214
|
const lastMsg = lodash.last(msgs);
|
|
215
215
|
const timestamp = lastMsg ? Number(lastMsg.ts) : Date.now();
|
|
216
|
-
this.onUndoMessageCallback(listUndo);
|
|
217
|
-
this.onMessageCallback(listMessages);
|
|
218
|
-
this.onUpdateQueueStatusCallback(queueStatus, timestamp);
|
|
216
|
+
await this.onUndoMessageCallback(listUndo);
|
|
217
|
+
await this.onMessageCallback(listMessages);
|
|
218
|
+
await this.onUpdateQueueStatusCallback(queueStatus, timestamp);
|
|
219
219
|
}
|
|
220
220
|
if (version == 1 && cmd == 521) {
|
|
221
221
|
const parsedData = (await utils.decodeEventData(parsed, this.cipherKey)).data;
|
|
@@ -240,9 +240,9 @@ class Listener extends stream.EventEmitter {
|
|
|
240
240
|
}
|
|
241
241
|
const lastMsg = lodash.last(groupMsgs);
|
|
242
242
|
const timestamp = lastMsg ? Number(lastMsg.ts) : Date.now();
|
|
243
|
-
this.onUndoMessageCallback(listUndo);
|
|
244
|
-
this.onMessageCallback(listMessages);
|
|
245
|
-
this.onUpdateQueueStatusCallback(queueStatus, timestamp);
|
|
243
|
+
await this.onUndoMessageCallback(listUndo);
|
|
244
|
+
await this.onMessageCallback(listMessages);
|
|
245
|
+
await this.onUpdateQueueStatusCallback(queueStatus, timestamp);
|
|
246
246
|
}
|
|
247
247
|
if ([510, 511, 610, 611, 603, 604].includes(cmd)) {
|
|
248
248
|
const parsedData = (await utils.decodeEventData(parsed, this.cipherKey)).data;
|
|
@@ -345,8 +345,8 @@ class Listener extends stream.EventEmitter {
|
|
|
345
345
|
}
|
|
346
346
|
const lastMsg = reacts.length > 0 ? lodash.last(reacts) : reactGroups.length > 0 ? lodash.last(reactGroups) : null;
|
|
347
347
|
const timestamp = lastMsg ? Number(lastMsg.ts) : Date.now();
|
|
348
|
-
this.onReactionCallback(listReactions);
|
|
349
|
-
this.onUpdateQueueStatusCallback(queueStatus, timestamp);
|
|
348
|
+
await this.onReactionCallback(listReactions);
|
|
349
|
+
await this.onUpdateQueueStatusCallback(queueStatus, timestamp);
|
|
350
350
|
}
|
|
351
351
|
if (cmd == 510) {
|
|
352
352
|
const parsedData = (await utils.decodeEventData(parsed, this.cipherKey)).data;
|
|
@@ -365,9 +365,9 @@ class Listener extends stream.EventEmitter {
|
|
|
365
365
|
});
|
|
366
366
|
const lastMsg = lodash.last(msgs);
|
|
367
367
|
const timestamp = lastMsg ? Number(lastMsg.ts) : Date.now();
|
|
368
|
-
this.
|
|
369
|
-
this.onOldMessageCallback(responseMsgs);
|
|
370
|
-
this.
|
|
368
|
+
await this.onUndoMessageCallback(responseUndos);
|
|
369
|
+
await this.onOldMessageCallback(responseMsgs);
|
|
370
|
+
await this.onUpdateQueueStatusCallback(queueStatus, timestamp);
|
|
371
371
|
this.emit('old_messages', responseMsgs);
|
|
372
372
|
}
|
|
373
373
|
if (cmd == 511) {
|
|
@@ -387,9 +387,9 @@ class Listener extends stream.EventEmitter {
|
|
|
387
387
|
}
|
|
388
388
|
const lastMsg = lodash.last(groupMsgs);
|
|
389
389
|
const timestamp = lastMsg ? Number(lastMsg.ts) : Date.now();
|
|
390
|
-
this.
|
|
391
|
-
this.onOldMessageCallback(responseMsgs);
|
|
392
|
-
this.
|
|
390
|
+
await this.onUndoMessageCallback(responseUndos);
|
|
391
|
+
await this.onOldMessageCallback(responseMsgs);
|
|
392
|
+
await this.onUpdateQueueStatusCallback(queueStatus, timestamp);
|
|
393
393
|
this.emit('old_messages', responseMsgs);
|
|
394
394
|
}
|
|
395
395
|
if (cmd == 518) {
|
|
@@ -400,8 +400,8 @@ class Listener extends stream.EventEmitter {
|
|
|
400
400
|
const listMessage = [...parseMsgs, ...parseGroupMsgs];
|
|
401
401
|
const lastMsg = lodash.last(listMessage);
|
|
402
402
|
const timestamp = lastMsg ? Number(lastMsg.ts) : Date.now();
|
|
403
|
-
this.
|
|
404
|
-
this.
|
|
403
|
+
await this.onOldMessageCallback(listMessage);
|
|
404
|
+
await this.onUpdateQueueStatusCallback(queueStatus, timestamp);
|
|
405
405
|
this.emit('old_messages', listMessage);
|
|
406
406
|
}
|
|
407
407
|
if (cmd == 602 && subCmd == 0) {
|
|
@@ -659,9 +659,11 @@ class Listener extends stream.EventEmitter {
|
|
|
659
659
|
const retryConfig = this.retries[errorCode];
|
|
660
660
|
if (retryConfig) {
|
|
661
661
|
let { times, count, max } = retryConfig;
|
|
662
|
-
if (max != null && count >= max) {
|
|
662
|
+
// if (max != null && count >= max) {
|
|
663
|
+
// return null;
|
|
664
|
+
// }
|
|
665
|
+
if (count >= 3)
|
|
663
666
|
return null;
|
|
664
|
-
}
|
|
665
667
|
this.retries[errorCode].count = ((_a = this.retries[errorCode].count) !== null && _a !== void 0 ? _a : 0) + 1;
|
|
666
668
|
if (typeof times === 'number') {
|
|
667
669
|
return times;
|