Skip to content

Commit fb6907f

Browse files
committed
socket: changes to onWhatsApp
1 parent 86d4575 commit fb6907f

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

src/Socket/socket.ts

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -259,12 +259,18 @@ export const makeSocket = (config: SocketConfig) => {
259259
}
260260

261261
const onWhatsApp = async (...jids: string[]) => {
262-
const usyncQuery = new USyncQuery().withLIDProtocol().withContactProtocol()
262+
let usyncQuery = new USyncQuery().withLIDProtocol()
263263

264+
let contactEnabled = false;
264265
for (const jid of jids) {
265266
if (isLidUser(jid)) {
266-
usyncQuery.withUser(new USyncUser().withId(jid)) // intentional
267+
// usyncQuery.withUser(new USyncUser().withLid(jid)) // intentional but needs JID too
268+
continue;
267269
} else {
270+
if (!contactEnabled) {
271+
contactEnabled = true
272+
usyncQuery = usyncQuery.withContactProtocol()
273+
}
268274
const phone = `+${jid.replace('+', '').split('@')[0]?.split(':')[0]}`
269275
usyncQuery.withUser(new USyncUser().withPhone(phone))
270276
}

0 commit comments

Comments
 (0)