@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.
@@ -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
- const { type, ciphertext } = await signalRepository
247
- .encryptMessage({ jid, data: bytes });
248
- if (type === 'pkmsg') {
249
- shouldIncludeDeviceIdentity = true;
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
- const node = {
252
- tag: 'to',
253
- attrs: { jid },
254
- content: [{
255
- tag: 'enc',
256
- attrs: {
257
- v: '2',
258
- type,
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 }) => {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@langitdeveloper/baileys",
3
- "version": "2.2.3",
3
+ "version": "2.2.4",
4
4
  "description": "WhatsApp API Modification By Langit",
5
5
  "keywords": [
6
6
  "whatsapp",