Deploy: 2026-06-24 23:30:56

This commit is contained in:
Hamza-Ayed
2026-06-24 23:30:56 +03:00
parent 7085065fbe
commit c1c99654a2
+20 -1
View File
@@ -590,7 +590,26 @@ async function sendMessage(session_key, phone, message, mediaUrl = null, audioBa
jid = phoneToLid.get(phone);
console.log(`[LID] Routing reply to ${phone} via LID: ${jid}`);
} else {
jid = `${phone}@s.whatsapp.net`;
// Query WhatsApp to resolve the correct JID/LID for this phone number.
// This is CRITICAL for newer WhatsApp versions (especially iOS) to prevent
// E2EE session conflicts and the "Waiting for this message" decryption delay.
try {
console.log(`[JID Resolve] Resolving JID for ${phone}...`);
const [result] = await sock.onWhatsApp(phone);
if (result && result.exists) {
jid = result.jid;
console.log(`[JID Resolve] Successfully resolved JID for ${phone}: ${jid}`);
// Cache it for subsequent messages
if (jid.endsWith('@lid')) {
phoneToLid.set(phone, jid);
}
} else {
jid = `${phone}@s.whatsapp.net`;
}
} catch (err) {
console.error(`[JID Resolve] Failed to query onWhatsApp for ${phone}:`, err.message);
jid = `${phone}@s.whatsapp.net`;
}
}
let sentMsg;