@open-wa/wa-automate 4.37.1 → 4.37.2

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.
@@ -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.
@@ -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 && [message].filter(typeof fil == "function" ? fil : x => x)[0];
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
- return ((yield preProcessors_1.MessagePreprocessors[this._createConfig.messagePreprocessor](m, this)) || message);
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
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@open-wa/wa-automate",
3
- "version": "4.37.1",
3
+ "version": "4.37.2",
4
4
  "licenseCheckUrl": "https://funcs.openwa.dev/license-check",
5
5
  "brokenMethodReportUrl": "https://funcs.openwa.dev/report-bm",
6
6
  "patches": "https://cdn.openwa.dev/patches.json",