@periskope/baileys 6.7.10-alpha.0 → 6.7.10-alpha.1

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.
@@ -22,6 +22,7 @@ const makeMessagesRecvSocket = (config) => {
22
22
  const { ev, authState, ws, processingMutex, signalRepository, query, upsertMessage, resyncAppState, onUnexpectedError, assertSessions, sendNode, relayMessage, sendReceipt, uploadPreKeys, sendPeerDataOperationMessage, } = sock;
23
23
  /** this mutex ensures that each retryRequest will wait for the previous one to finish */
24
24
  const retryMutex = (0, make_mutex_1.makeMutex)();
25
+ const keyRetryMap = new Map();
25
26
  const msgRetryCache = config.msgRetryCounterCache || new node_cache_1.default({
26
27
  stdTTL: Defaults_1.DEFAULT_CACHE_TTLS.MSG_RETRY,
27
28
  useClones: false
@@ -783,13 +784,20 @@ const makeMessagesRecvSocket = (config) => {
783
784
  // it means -- the message hasn't reached all devices yet
784
785
  // we'll retry sending the message here
785
786
  if (attrs.phash) {
786
- logger.info({ attrs }, 'received phash in ack, resending message...');
787
- const msg = await getMessage(key);
788
- if (msg) {
789
- await relayMessage(key.remoteJid, msg, { messageId: key.id, useUserDevicesCache: false });
787
+ const retryCount = keyRetryMap.get(key.id) || 0;
788
+ keyRetryMap.set(key.id, retryCount + 1);
789
+ if (retryCount > 3) {
790
+ logger.warn({ attrs }, 'ignoring phash in ack, as it has been retried too many times');
790
791
  }
791
792
  else {
792
- logger.warn({ attrs }, 'could not send message again, as it was not found');
793
+ logger.info({ attrs }, 'received phash in ack, resending message...');
794
+ const msg = await getMessage(key);
795
+ if (msg) {
796
+ await relayMessage(key.remoteJid, msg, { messageId: key.id, useUserDevicesCache: false });
797
+ }
798
+ else {
799
+ logger.warn({ attrs }, 'could not send message again, as it was not found');
800
+ }
793
801
  }
794
802
  }
795
803
  // error in acknowledgement,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@periskope/baileys",
3
- "version": "6.7.10-alpha.0",
3
+ "version": "6.7.10-alpha.1",
4
4
  "description": "Periskope Fork of Baileys",
5
5
  "keywords": [
6
6
  "whatsapp",