@realvare/based 2.7.1 → 2.7.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.
- package/lib/Socket/messages-recv.js +35 -15
- package/package.json +1 -1
|
@@ -235,12 +235,22 @@ const makeMessagesRecvSocket = (config) => {
|
|
|
235
235
|
}
|
|
236
236
|
}
|
|
237
237
|
};
|
|
238
|
-
const handleGroupNotification = (participant, child, msg) => {
|
|
238
|
+
const handleGroupNotification = async (participant, child, groupJid, msg) => {
|
|
239
239
|
var _a, _b, _c, _d;
|
|
240
|
-
const participantJid =
|
|
240
|
+
const participantJid = (((_b = (_a = (0, WABinary_1.getBinaryNodeChild)(child, 'participant')) === null || _a === void 0 ? void 0 : _a.attrs) === null || _b === void 0 ? void 0 : _b.jid) || participant);
|
|
241
241
|
switch (child === null || child === void 0 ? void 0 : child.tag) {
|
|
242
242
|
case 'create':
|
|
243
|
-
|
|
243
|
+
let metadata = (0, groups_1.extractGroupMetadata)(child);
|
|
244
|
+
const fullMetadata = await groupMetadata(groupJid);
|
|
245
|
+
if (metadata.owner && metadata.owner.endsWith('@lid')) {
|
|
246
|
+
const found = fullMetadata.participants.find(p => p.id === metadata.owner);
|
|
247
|
+
metadata.owner = found?.jid || (0, WABinary_1.lidToJid)(metadata.owner);
|
|
248
|
+
}
|
|
249
|
+
let resolvedAuthor = participant;
|
|
250
|
+
if (participant.endsWith('@lid')) {
|
|
251
|
+
const found = fullMetadata.participants.find(p => p.id === participant);
|
|
252
|
+
resolvedAuthor = found?.jid || (0, WABinary_1.lidToJid)(participant);
|
|
253
|
+
}
|
|
244
254
|
msg.messageStubType = Types_1.WAMessageStubType.GROUP_CREATE;
|
|
245
255
|
msg.messageStubParameters = [metadata.subject];
|
|
246
256
|
msg.key = { participant: metadata.owner };
|
|
@@ -251,7 +261,7 @@ const makeMessagesRecvSocket = (config) => {
|
|
|
251
261
|
}]);
|
|
252
262
|
ev.emit('groups.upsert', [{
|
|
253
263
|
...metadata,
|
|
254
|
-
author:
|
|
264
|
+
author: resolvedAuthor
|
|
255
265
|
}]);
|
|
256
266
|
break;
|
|
257
267
|
case 'ephemeral':
|
|
@@ -265,7 +275,7 @@ const makeMessagesRecvSocket = (config) => {
|
|
|
265
275
|
break;
|
|
266
276
|
case 'modify':
|
|
267
277
|
const oldNumber = (0, WABinary_1.getBinaryNodeChildren)(child, 'participant').map(p => p.attrs.jid);
|
|
268
|
-
msg.messageStubParameters = oldNumber
|
|
278
|
+
msg.messageStubParameters = oldNumber || [];
|
|
269
279
|
msg.messageStubType = Types_1.WAMessageStubType.GROUP_PARTICIPANT_CHANGE_NUMBER;
|
|
270
280
|
break;
|
|
271
281
|
case 'promote':
|
|
@@ -283,7 +293,7 @@ const makeMessagesRecvSocket = (config) => {
|
|
|
283
293
|
child.tag === 'remove') {
|
|
284
294
|
msg.messageStubType = Types_1.WAMessageStubType.GROUP_PARTICIPANT_LEAVE;
|
|
285
295
|
}
|
|
286
|
-
msg.messageStubParameters = participants
|
|
296
|
+
msg.messageStubParameters = participants;
|
|
287
297
|
break;
|
|
288
298
|
case 'subject':
|
|
289
299
|
msg.messageStubType = Types_1.WAMessageStubType.GROUP_CHANGE_SUBJECT;
|
|
@@ -331,10 +341,26 @@ const makeMessagesRecvSocket = (config) => {
|
|
|
331
341
|
msg.messageStubType = Types_1.WAMessageStubType.GROUP_MEMBERSHIP_JOIN_APPROVAL_REQUEST_NON_ADMIN_ADD;
|
|
332
342
|
msg.messageStubParameters = [participantJid, isDenied ? 'revoked' : 'rejected'];
|
|
333
343
|
break;
|
|
334
|
-
break;
|
|
335
344
|
default:
|
|
336
345
|
// console.log("BAILEYS-DEBUG:", JSON.stringify({ ...child, content: Buffer.isBuffer(child.content) ? child.content.toString() : child.content, participant }, null, 2))
|
|
337
346
|
}
|
|
347
|
+
// Resolve LIDs to real JIDs for all messageStubParameters
|
|
348
|
+
if (msg.messageStubParameters) {
|
|
349
|
+
const metadata = await groupMetadata(groupJid);
|
|
350
|
+
msg.messageStubParameters = await Promise.all(msg.messageStubParameters.map(async (param) => {
|
|
351
|
+
if (typeof param === 'string' && param.endsWith('@lid')) {
|
|
352
|
+
const found = metadata.participants.find(p => p.id === param);
|
|
353
|
+
return found?.jid || (0, WABinary_1.lidToJid)(param);
|
|
354
|
+
}
|
|
355
|
+
return param;
|
|
356
|
+
}));
|
|
357
|
+
}
|
|
358
|
+
// Also resolve key.participant if needed
|
|
359
|
+
if (msg.key?.participant && msg.key.participant.endsWith('@lid')) {
|
|
360
|
+
const metadata = await groupMetadata(groupJid);
|
|
361
|
+
const found = metadata.participants.find(p => p.id === msg.key.participant);
|
|
362
|
+
msg.key.participant = found?.jid || (0, WABinary_1.lidToJid)(msg.key.participant);
|
|
363
|
+
}
|
|
338
364
|
};
|
|
339
365
|
const handleNewsletterNotification = (id, node) => {
|
|
340
366
|
const messages = (0, WABinary_1.getBinaryNodeChild)(node, 'messages');
|
|
@@ -407,7 +433,7 @@ const makeMessagesRecvSocket = (config) => {
|
|
|
407
433
|
handleMexNewsletterNotification(node.attrs.from, child);
|
|
408
434
|
break;
|
|
409
435
|
case 'w:gp2':
|
|
410
|
-
handleGroupNotification(node.attrs.participant, child, result);
|
|
436
|
+
await handleGroupNotification(node.attrs.participant, child, from, result);
|
|
411
437
|
break;
|
|
412
438
|
case 'mediaretry':
|
|
413
439
|
const event = (0, Utils_1.decodeMediaRetryNode)(node);
|
|
@@ -659,7 +685,6 @@ const makeMessagesRecvSocket = (config) => {
|
|
|
659
685
|
update: { status: WAProto_1.proto.WebMessageInfo.Status.SERVER_ACK }
|
|
660
686
|
})));
|
|
661
687
|
}
|
|
662
|
-
|
|
663
688
|
if (attrs.type === 'retry') {
|
|
664
689
|
// correctly set who is asking for the retry
|
|
665
690
|
key.participant = key.participant || attrs.from;
|
|
@@ -1051,11 +1076,9 @@ const makeMessagesRecvSocket = (config) => {
|
|
|
1051
1076
|
});
|
|
1052
1077
|
ev.on('connection.update', (update) => {
|
|
1053
1078
|
const { connection, lastDisconnect } = update;
|
|
1054
|
-
|
|
1055
1079
|
if (connection === 'close') {
|
|
1056
1080
|
const statusCode = lastDisconnect?.error?.output?.statusCode;
|
|
1057
1081
|
const shouldReconnect = statusCode !== Types_1.DisconnectReason.loggedOut;
|
|
1058
|
-
|
|
1059
1082
|
if (shouldReconnect) {
|
|
1060
1083
|
logger.info('Connection closed, will handle reconnection automatically');
|
|
1061
1084
|
} else {
|
|
@@ -1064,14 +1087,12 @@ const makeMessagesRecvSocket = (config) => {
|
|
|
1064
1087
|
} else if (connection === 'open') {
|
|
1065
1088
|
sendActiveReceipts = true;
|
|
1066
1089
|
}
|
|
1067
|
-
|
|
1068
1090
|
// Update sendActiveReceipts based on connection status
|
|
1069
1091
|
if (typeof update.isOnline !== 'undefined') {
|
|
1070
1092
|
sendActiveReceipts = update.isOnline;
|
|
1071
1093
|
logger.trace(`sendActiveReceipts set to "${sendActiveReceipts}"`);
|
|
1072
1094
|
}
|
|
1073
1095
|
});
|
|
1074
|
-
|
|
1075
1096
|
// Enhanced retry logic for stuck pending messages with anti-ban delays
|
|
1076
1097
|
ev.on('messages.update', (updates) => {
|
|
1077
1098
|
const config = (0, performance_config_1.getPerformanceConfig)();
|
|
@@ -1079,7 +1100,6 @@ const makeMessagesRecvSocket = (config) => {
|
|
|
1079
1100
|
if (update.update.status === WAProto_1.proto.WebMessageInfo.Status.PENDING &&
|
|
1080
1101
|
Date.now() - (update.update.timestamp || 0) > 30000) { // 30 seconds
|
|
1081
1102
|
logger.debug({ key: update.key }, 'retrying stuck pending message with anti-ban delay');
|
|
1082
|
-
|
|
1083
1103
|
// Apply anti-ban delay before retry
|
|
1084
1104
|
setTimeout(async () => {
|
|
1085
1105
|
try {
|
|
@@ -1104,4 +1124,4 @@ const makeMessagesRecvSocket = (config) => {
|
|
|
1104
1124
|
requestPlaceholderResend,
|
|
1105
1125
|
};
|
|
1106
1126
|
};
|
|
1107
|
-
exports.makeMessagesRecvSocket = makeMessagesRecvSocket;
|
|
1127
|
+
exports.makeMessagesRecvSocket = makeMessagesRecvSocket;
|