@periskope/baileys 6.7.10-alpha.1 → 6.7.12-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,7 +22,6 @@ 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();
|
|
26
25
|
const msgRetryCache = config.msgRetryCounterCache || new node_cache_1.default({
|
|
27
26
|
stdTTL: Defaults_1.DEFAULT_CACHE_TTLS.MSG_RETRY,
|
|
28
27
|
useClones: false
|
|
@@ -484,7 +483,7 @@ const makeMessagesRecvSocket = (config) => {
|
|
|
484
483
|
}
|
|
485
484
|
}
|
|
486
485
|
};
|
|
487
|
-
const handleReceipt = async (node
|
|
486
|
+
const handleReceipt = async (node) => {
|
|
488
487
|
var _a, _b;
|
|
489
488
|
const { attrs, content } = node;
|
|
490
489
|
const isLid = attrs.from.includes('lid');
|
|
@@ -570,7 +569,7 @@ const makeMessagesRecvSocket = (config) => {
|
|
|
570
569
|
await sendMessageAck(node);
|
|
571
570
|
}
|
|
572
571
|
};
|
|
573
|
-
const handleNotification = async (node
|
|
572
|
+
const handleNotification = async (node) => {
|
|
574
573
|
const remoteJid = node.attrs.from;
|
|
575
574
|
if (shouldIgnoreJid(remoteJid) && remoteJid !== '@s.whatsapp.net') {
|
|
576
575
|
logger.debug({ remoteJid, id: node.attrs.id }, 'ignored notification');
|
|
@@ -603,12 +602,8 @@ const makeMessagesRecvSocket = (config) => {
|
|
|
603
602
|
await sendMessageAck(node);
|
|
604
603
|
}
|
|
605
604
|
};
|
|
606
|
-
const handleMessage = async (node
|
|
605
|
+
const handleMessage = async (node) => {
|
|
607
606
|
var _a, _b, _c;
|
|
608
|
-
if (offline) {
|
|
609
|
-
await sendMessageAck(node);
|
|
610
|
-
return;
|
|
611
|
-
}
|
|
612
607
|
if (shouldIgnoreJid(node.attrs.from) && node.attrs.from !== '@s.whatsapp.net') {
|
|
613
608
|
logger.debug({ key: node.attrs.key }, 'ignored message');
|
|
614
609
|
await sendMessageAck(node);
|
|
@@ -780,26 +775,19 @@ const makeMessagesRecvSocket = (config) => {
|
|
|
780
775
|
};
|
|
781
776
|
const handleBadAck = async ({ attrs }) => {
|
|
782
777
|
const key = { remoteJid: attrs.from, fromMe: true, id: attrs.id };
|
|
783
|
-
//
|
|
784
|
-
//
|
|
785
|
-
//
|
|
786
|
-
|
|
787
|
-
|
|
788
|
-
|
|
789
|
-
|
|
790
|
-
|
|
791
|
-
|
|
792
|
-
|
|
793
|
-
|
|
794
|
-
|
|
795
|
-
|
|
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
|
-
}
|
|
801
|
-
}
|
|
802
|
-
}
|
|
778
|
+
// WARNING: REFRAIN FROM ENABLING THIS FOR NOW. IT WILL CAUSE A LOOP
|
|
779
|
+
// // current hypothesis is that if pash is sent in the ack
|
|
780
|
+
// // it means -- the message hasn't reached all devices yet
|
|
781
|
+
// // we'll retry sending the message here
|
|
782
|
+
// if(attrs.phash) {
|
|
783
|
+
// logger.info({ attrs }, 'received phash in ack, resending message...')
|
|
784
|
+
// const msg = await getMessage(key)
|
|
785
|
+
// if(msg) {
|
|
786
|
+
// await relayMessage(key.remoteJid!, msg, { messageId: key.id!, useUserDevicesCache: false })
|
|
787
|
+
// } else {
|
|
788
|
+
// logger.warn({ attrs }, 'could not send message again, as it was not found')
|
|
789
|
+
// }
|
|
790
|
+
// }
|
|
803
791
|
// error in acknowledgement,
|
|
804
792
|
// device could not display the message
|
|
805
793
|
if (attrs.error) {
|
|
@@ -851,7 +839,7 @@ const makeMessagesRecvSocket = (config) => {
|
|
|
851
839
|
onUnexpectedError(new Error(`unknown offline node type: ${type}`), 'processing offline node');
|
|
852
840
|
continue;
|
|
853
841
|
}
|
|
854
|
-
await nodeProcessor(node
|
|
842
|
+
await nodeProcessor(node);
|
|
855
843
|
}
|
|
856
844
|
isProcessing = false;
|
|
857
845
|
};
|
package/lib/Utils/messages.js
CHANGED
|
@@ -449,10 +449,10 @@ const generateWAMessageFromContent = (jid, message, options) => {
|
|
|
449
449
|
if (quoted) {
|
|
450
450
|
const participant = quoted.key.fromMe ? userJid : (quoted.participant || quoted.key.participant || quoted.key.remoteJid);
|
|
451
451
|
let quotedMsg = (0, exports.normalizeMessageContent)(quoted.message);
|
|
452
|
-
const msgType = (0, exports.getContentType)(quotedMsg);
|
|
453
|
-
// strip any redundant properties
|
|
454
|
-
quotedMsg = WAProto_1.proto.Message.fromObject({ [msgType]: quotedMsg[msgType] });
|
|
455
452
|
if (quotedMsg) {
|
|
453
|
+
const msgType = (0, exports.getContentType)(quotedMsg);
|
|
454
|
+
// strip any redundant properties
|
|
455
|
+
quotedMsg = WAProto_1.proto.Message.fromObject({ [msgType]: quotedMsg[msgType] });
|
|
456
456
|
const quotedContent = quotedMsg[msgType];
|
|
457
457
|
if (typeof quotedContent === 'object' && quotedContent && 'contextInfo' in quotedContent) {
|
|
458
458
|
delete quotedContent.contextInfo;
|
|
@@ -217,6 +217,22 @@ const processMessage = async (message, { shouldProcessHistoryMsg, placeholderRes
|
|
|
217
217
|
}
|
|
218
218
|
}
|
|
219
219
|
}
|
|
220
|
+
case WAProto_1.proto.Message.ProtocolMessage.Type.MESSAGE_EDIT:
|
|
221
|
+
ev.emit('messages.update', [
|
|
222
|
+
{
|
|
223
|
+
key: protocolMsg.key,
|
|
224
|
+
update: {
|
|
225
|
+
message: {
|
|
226
|
+
editedMessage: {
|
|
227
|
+
message: protocolMsg.editedMessage
|
|
228
|
+
}
|
|
229
|
+
},
|
|
230
|
+
messageTimestamp: protocolMsg.timestampMs
|
|
231
|
+
? Math.floor((0, generics_1.toNumber)(protocolMsg.timestampMs) / 1000)
|
|
232
|
+
: message.messageTimestamp
|
|
233
|
+
}
|
|
234
|
+
}
|
|
235
|
+
]);
|
|
220
236
|
break;
|
|
221
237
|
}
|
|
222
238
|
}
|
package/lib/WABinary/encode.js
CHANGED
|
@@ -160,7 +160,7 @@ const encodeBinaryNodeInner = ({ tag, attrs, content }, opts, buffer) => {
|
|
|
160
160
|
}
|
|
161
161
|
for (const char of str) {
|
|
162
162
|
const isInNibbleRange = char >= '0' && char <= '9';
|
|
163
|
-
if (!isInNibbleRange && !(char >= 'A' && char <= 'F')
|
|
163
|
+
if (!isInNibbleRange && !(char >= 'A' && char <= 'F')) {
|
|
164
164
|
return false;
|
|
165
165
|
}
|
|
166
166
|
}
|