socket: changes to onWhatsApp

This commit is contained in:
Rajeh Taher
2025-09-26 09:26:59 +03:00
parent 86d45758bb
commit fb6907f9ee
+8 -2
View File
@@ -259,12 +259,18 @@ export const makeSocket = (config: SocketConfig) => {
} }
const onWhatsApp = async (...jids: string[]) => { const onWhatsApp = async (...jids: string[]) => {
const usyncQuery = new USyncQuery().withLIDProtocol().withContactProtocol() let usyncQuery = new USyncQuery().withLIDProtocol()
let contactEnabled = false;
for (const jid of jids) { for (const jid of jids) {
if (isLidUser(jid)) { if (isLidUser(jid)) {
usyncQuery.withUser(new USyncUser().withId(jid)) // intentional // usyncQuery.withUser(new USyncUser().withLid(jid)) // intentional but needs JID too
continue;
} else { } else {
if (!contactEnabled) {
contactEnabled = true
usyncQuery = usyncQuery.withContactProtocol()
}
const phone = `+${jid.replace('+', '').split('@')[0]?.split(':')[0]}` const phone = `+${jid.replace('+', '').split('@')[0]?.split(':')[0]}`
usyncQuery.withUser(new USyncUser().withPhone(phone)) usyncQuery.withUser(new USyncUser().withPhone(phone))
} }