@vinzsocket/baileys 3.0.25 → 3.0.30

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.
@@ -330,6 +330,40 @@ export const normalizeToNativeFlowButtons = (buttons) => {
330
330
  return null;
331
331
  }).filter(Boolean);
332
332
  };
333
+ /**
334
+ * WhatsApp requires interactive/button/list/product messages to be wrapped in a
335
+ * viewOnceMessage with deviceListMetadataVersion set, or the recipient's client
336
+ * silently drops the buttons (the message still delivers, but renders empty/invisible).
337
+ * This mirrors the official Baileys `patchMessageBeforeSending` behavior.
338
+ *
339
+ * Safe to call on any message content object `m` (the shape produced internally
340
+ * while building a proto.IMessage, i.e. `{ interactiveMessage: {...} }` etc).
341
+ * No-ops if `m` is already wrapped, or doesn't need wrapping.
342
+ */
343
+ export const patchInteractiveMessage = (m) => {
344
+ if (!m || typeof m !== 'object') return m;
345
+ const needsInteractivePatch = !m.viewOnceMessage && (
346
+ m.interactiveMessage ||
347
+ m.buttonsMessage ||
348
+ m.templateMessage ||
349
+ m.listMessage ||
350
+ m.productMessage
351
+ );
352
+ if (!needsInteractivePatch) return m;
353
+ const { messageContextInfo: existingContextInfo, ...rest } = m;
354
+ return {
355
+ viewOnceMessage: {
356
+ message: {
357
+ ...rest,
358
+ messageContextInfo: {
359
+ deviceListMetadata: {},
360
+ deviceListMetadataVersion: 2,
361
+ ...existingContextInfo
362
+ }
363
+ }
364
+ }
365
+ };
366
+ };
333
367
  export const hasNonNullishProperty = (message, key) => {
334
368
  return (typeof message === 'object' &&
335
369
  message !== null &&
@@ -669,6 +703,7 @@ export const generateWAMessageContent = async (message, options) => {
669
703
  m.messageContextInfo.messageSecret = randomBytes(32);
670
704
  }
671
705
  }
706
+ m = patchInteractiveMessage(m);
672
707
  return WAProto.Message.create(m);
673
708
  };
674
709
  export const generateWAMessageFromContent = (jid, message, options) => {
@@ -723,6 +758,7 @@ export const generateWAMessageFromContent = (jid, message, options) => {
723
758
  //ephemeralSettingTimestamp: options.ephemeralOptions.eph_setting_ts?.toString()
724
759
  };
725
760
  }
761
+ message = patchInteractiveMessage(message);
726
762
  message = WAProto.Message.create(message);
727
763
  const messageJSON = {
728
764
  key: {
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@vinzsocket/baileys",
3
3
  "type": "module",
4
- "version": "3.0.25",
4
+ "version": "3.0.30",
5
5
  "description": "A WebSockets library for interacting with WhatsApp Web",
6
6
  "keywords": [
7
7
  "whatsapp",