@langitdeveloper/baileys 2.2.3 → 2.2.4
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-send.js +29 -20
- package/package.json +1 -1
|
@@ -242,27 +242,36 @@ const makeMessagesSocket = (config) => {
|
|
|
242
242
|
const patched = await patchMessageBeforeSending(message, jids);
|
|
243
243
|
const bytes = (0, Utils_1.encodeWAMessage)(patched);
|
|
244
244
|
let shouldIncludeDeviceIdentity = false;
|
|
245
|
-
const nodes = await Promise.all(jids.map(async (jid) => {
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
245
|
+
const nodes = (await Promise.all(jids.map(async (jid) => {
|
|
246
|
+
try {
|
|
247
|
+
const { type, ciphertext } = await signalRepository
|
|
248
|
+
.encryptMessage({ jid, data: bytes });
|
|
249
|
+
if (type === 'pkmsg') {
|
|
250
|
+
shouldIncludeDeviceIdentity = true;
|
|
251
|
+
}
|
|
252
|
+
const node = {
|
|
253
|
+
tag: 'to',
|
|
254
|
+
attrs: { jid },
|
|
255
|
+
content: [{
|
|
256
|
+
tag: 'enc',
|
|
257
|
+
attrs: {
|
|
258
|
+
v: '2',
|
|
259
|
+
type,
|
|
260
|
+
...extraAttrs || {}
|
|
261
|
+
},
|
|
262
|
+
content: ciphertext
|
|
263
|
+
}]
|
|
264
|
+
};
|
|
265
|
+
return node;
|
|
250
266
|
}
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
...extraAttrs || {}
|
|
260
|
-
},
|
|
261
|
-
content: ciphertext
|
|
262
|
-
}]
|
|
263
|
-
};
|
|
264
|
-
return node;
|
|
265
|
-
}));
|
|
267
|
+
catch (error) {
|
|
268
|
+
// fix: "SessionError: No sessions" (atau error encrypt lain) buat 1 device jangan
|
|
269
|
+
// sampe nge-reject Promise.all dan bikin proses crash total - skip device ini aja,
|
|
270
|
+
// device lain tetep kekirim normal.
|
|
271
|
+
logger.warn({ jid, trace: error?.stack, err: error?.toString?.() ?? error }, 'failed to encrypt message for device, skipping (no session?)');
|
|
272
|
+
return null;
|
|
273
|
+
}
|
|
274
|
+
}))).filter(Boolean);
|
|
266
275
|
return { nodes, shouldIncludeDeviceIdentity };
|
|
267
276
|
};
|
|
268
277
|
const relayMessage = async (jid, message, { messageId: msgId, participant, additionalAttributes, additionalNodes, useUserDevicesCache, cachedGroupMetadata, useCachedGroupMetadata, statusJidList, AI = true }) => {
|