@realvare/based 2.5.6 → 2.5.7

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.
@@ -1,3 +1,3 @@
1
1
  {
2
- "version": [2, 3000, 1023888953]
2
+ "version": [2, 3000, 1027934701]
3
3
  }
@@ -640,12 +640,25 @@ const makeMessagesRecvSocket = (config) => {
640
640
  }
641
641
  }
642
642
  else {
643
+ // Log ACK status changes for monitoring
644
+ ids.forEach(id => {
645
+ const statusName = Object.keys(WAProto_1.proto.WebMessageInfo.Status)[status] || `UNKNOWN_${status}`;
646
+ logger.debug({ remoteJid, id, status: statusName }, 'ACK status update');
647
+ });
643
648
  ev.emit('messages.update', ids.map(id => ({
644
649
  key: { ...key, id },
645
650
  update: { status }
646
651
  })));
647
652
  }
648
653
  }
654
+ // Emit SERVER_ACK for error status to fix stuck ACKs
655
+ if (status === WAProto_1.proto.WebMessageInfo.Status.ERROR) {
656
+ ev.emit('messages.update', ids.map(id => ({
657
+ key: { ...key, id },
658
+ update: { status: WAProto_1.proto.WebMessageInfo.Status.SERVER_ACK }
659
+ })));
660
+ }
661
+
649
662
  if (attrs.type === 'retry') {
650
663
  // correctly set who is asking for the retry
651
664
  key.participant = key.participant || attrs.from;
@@ -1041,6 +1054,22 @@ const makeMessagesRecvSocket = (config) => {
1041
1054
  logger.trace(`sendActiveReceipts set to "${sendActiveReceipts}"`);
1042
1055
  }
1043
1056
  });
1057
+
1058
+ // Retry logic for stuck pending messages
1059
+ ev.on('messages.update', (updates) => {
1060
+ updates.forEach(update => {
1061
+ if (update.update.status === WAProto_1.proto.WebMessageInfo.Status.PENDING &&
1062
+ Date.now() - (update.update.timestamp || 0) > 30000) { // 30 seconds
1063
+ logger.debug({ key: update.key }, 'retrying stuck pending message');
1064
+ // Retry by re-sending the message
1065
+ getMessage(update.key).then(msg => {
1066
+ if (msg) {
1067
+ relayMessage(update.key.remoteJid, msg, { messageId: update.key.id });
1068
+ }
1069
+ }).catch(err => logger.error({ err, key: update.key }, 'failed to retry stuck message'));
1070
+ }
1071
+ });
1072
+ });
1044
1073
  return {
1045
1074
  ...sock,
1046
1075
  sendMessageAck,