@open-wa/wa-automate 4.37.1 → 4.37.2
Sign up to get free protection for your applications and to get access to all the features.
- package/dist/api/Client.d.ts +1 -0
- package/dist/api/Client.js +13 -2
- package/package.json +1 -1
package/dist/api/Client.d.ts
CHANGED
@@ -47,6 +47,7 @@ export declare class Client {
|
|
47
47
|
private _autoEmojiSet;
|
48
48
|
private _autoEmojiQ;
|
49
49
|
private _onLogoutSet;
|
50
|
+
private _preprocIdempotencyCheck;
|
50
51
|
/**
|
51
52
|
* This is used to track if a listener is already used via webhook. Before, webhooks used to be set once per listener. Now a listener can be set via multiple webhooks, or revoked from a specific webhook.
|
52
53
|
* For this reason, listeners assigned to a webhook are only set once and map through all possible webhooks to and fire only if the specific listener is assigned.
|
package/dist/api/Client.js
CHANGED
@@ -98,6 +98,7 @@ class Client {
|
|
98
98
|
carryoverConcurrencyCount: true
|
99
99
|
});
|
100
100
|
this._onLogoutSet = false;
|
101
|
+
this._preprocIdempotencyCheck = {};
|
101
102
|
/**
|
102
103
|
* This is used to track if a listener is already used via webhook. Before, webhooks used to be set once per listener. Now a listener can be set via multiple webhooks, or revoked from a specific webhook.
|
103
104
|
* For this reason, listeners assigned to a webhook are only set once and map through all possible webhooks to and fire only if the specific listener is assigned.
|
@@ -664,6 +665,11 @@ class Client {
|
|
664
665
|
// STANDARD SIMPLE LISTENERS
|
665
666
|
preprocessMessage(message) {
|
666
667
|
return __awaiter(this, void 0, void 0, function* () {
|
668
|
+
if (this._preprocIdempotencyCheck[message.id]) {
|
669
|
+
logging_1.log.info(`preprocessMessage: ${message.id} already being processed`);
|
670
|
+
return message;
|
671
|
+
}
|
672
|
+
this._preprocIdempotencyCheck[message.id] = true;
|
667
673
|
let fil = "";
|
668
674
|
try {
|
669
675
|
fil = typeof this._createConfig.preprocFilter == "function" ? this._createConfig.preprocFilter : typeof this._createConfig.preprocFilter == "string" ? eval(this._createConfig.preprocFilter || "undefined") : undefined;
|
@@ -671,10 +677,15 @@ class Client {
|
|
671
677
|
catch (error) {
|
672
678
|
//do nothing
|
673
679
|
}
|
674
|
-
const m = fil
|
680
|
+
const m = fil ? [message].filter(typeof fil == "function" ? fil : x => x)[0] : message;
|
681
|
+
logging_1.log.info(`Preproc START: ${this._createConfig.messagePreprocessor} ${fil} ${message.id} ${m.id}`);
|
675
682
|
if (m && this._createConfig.messagePreprocessor && preProcessors_1.MessagePreprocessors[this._createConfig.messagePreprocessor]) {
|
676
|
-
|
683
|
+
logging_1.log.info(`Preproccessing message: ${this._createConfig.messagePreprocessor}`);
|
684
|
+
const preprocres = ((yield preProcessors_1.MessagePreprocessors[this._createConfig.messagePreprocessor](m, this)) || message);
|
685
|
+
delete this._preprocIdempotencyCheck[message.id];
|
686
|
+
return preprocres;
|
677
687
|
}
|
688
|
+
delete this._preprocIdempotencyCheck[message.id];
|
678
689
|
return message;
|
679
690
|
});
|
680
691
|
}
|
package/package.json
CHANGED