@skycodee/baileys 8.0.10 → 8.0.11
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/chats.js +56 -17
- package/package.json +1 -1
package/lib/Socket/chats.js
CHANGED
|
@@ -245,25 +245,64 @@ export const makeChatsSocket = (config) => {
|
|
|
245
245
|
const listNode = getBinaryNodeChild(result, "list");
|
|
246
246
|
return getBinaryNodeChildren(listNode, "item").map(n => n.attrs.jid);
|
|
247
247
|
};
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
{
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
248
|
+
const updateBlockStatus = async (jid, action) => {
|
|
249
|
+
let lid;
|
|
250
|
+
let pn_jid;
|
|
251
|
+
let isLidUser = (jid) => /@lid/.test(jid)
|
|
252
|
+
let isPnUser = (jid) => /@s.whatsapp.net/.test(jid)
|
|
253
|
+
|
|
254
|
+
if (isLidUser(jid)) {
|
|
255
|
+
lid = jid;
|
|
256
|
+
|
|
257
|
+
if (action === 'block') {
|
|
258
|
+
const pn = await signalRepository.lidMapping.getPNForLID(jid);
|
|
259
|
+
if (!pn) {
|
|
260
|
+
throw new Boom(`Unable to resolve PN JID for LID: ${jid}`);
|
|
261
|
+
}
|
|
262
|
+
|
|
263
|
+
pn_jid = jidNormalizedUser(pn);
|
|
263
264
|
}
|
|
264
|
-
|
|
265
|
+
|
|
266
|
+
} else if (isPnUser(jid)) {
|
|
267
|
+
const mapped = await signalRepository.lidMapping.getLIDForPN(jid);
|
|
268
|
+
if (!mapped) {
|
|
269
|
+
throw new Boom(`Unable to resolve LID for PN JID: ${jid}`);
|
|
270
|
+
}
|
|
271
|
+
|
|
272
|
+
lid = mapped;
|
|
273
|
+
|
|
274
|
+
if (action === 'block') {
|
|
275
|
+
pn_jid = jidNormalizedUser(jid);
|
|
276
|
+
}
|
|
277
|
+
|
|
278
|
+
} else {
|
|
279
|
+
throw new Boom(`Invalid jid for block/unblock: ${jid}`);
|
|
280
|
+
}
|
|
281
|
+
|
|
282
|
+
const itemAttrs = {
|
|
283
|
+
action: action,
|
|
284
|
+
jid: lid
|
|
285
|
+
};
|
|
286
|
+
|
|
287
|
+
if (action === 'block' && pn_jid) {
|
|
288
|
+
itemAttrs.pn_jid = pn_jid;
|
|
289
|
+
}
|
|
290
|
+
|
|
291
|
+
await query({
|
|
292
|
+
tag: 'iq',
|
|
293
|
+
attrs: {
|
|
294
|
+
xmlns: 'blocklist',
|
|
295
|
+
to: S_WHATSAPP_NET,
|
|
296
|
+
type: 'set'
|
|
297
|
+
},
|
|
298
|
+
content: [
|
|
299
|
+
{
|
|
300
|
+
tag: 'item',
|
|
301
|
+
attrs: itemAttrs
|
|
302
|
+
}
|
|
303
|
+
]
|
|
265
304
|
});
|
|
266
|
-
|
|
305
|
+
};
|
|
267
306
|
const getBusinessProfile = async (jid) => {
|
|
268
307
|
const results = await query({
|
|
269
308
|
tag: "iq",
|