@vanzxy/baileys 1.3.0 → 1.3.5

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.
@@ -178,8 +178,8 @@ export const makeNewsletterSocket = (config) => {
178
178
  const fullMessage = proto.WebMessageInfo.fromObject({
179
179
  key: {
180
180
  remoteJid: newsletterJid,
181
- id: child.attrs.id || child.attrs.server_id,
182
- server_id: child.attrs.server_id,
181
+ id: child.attrs.message_id || child.attrs.server_id || child.attrs.id,
182
+ server_id: child.attrs.message_id || child.attrs.server_id,
183
183
  fromMe: false
184
184
  },
185
185
  message: messageProto,
@@ -269,7 +269,7 @@ const prepareProductMessage = async (message, options) => {
269
269
  */
270
270
  // Lia@Changes 21-04-26 --- Enhanced prepareStickerPackMessage
271
271
  const prepareStickerPackMessage = async (message, options) => {
272
- const { cover, stickers = [], name = '📦 Sticker Pack', publisher = 'GitHub: itsliaaa', description = '🏷️ itsliaaa/baileys' } = message;
272
+ const { cover, stickers = [], name = '📦 Sticker Pack', publisher = 'GitHub: vanzxy', description = '🏷️ vanzxy/baileys' } = message;
273
273
  if (stickers.length > 60) {
274
274
  throw new Boom('Sticker pack exceeds the maximum limit of 60 stickers', { statusCode: 400 });
275
275
  }
@@ -469,7 +469,7 @@ const prepareNativeFlowButtons = (message) => {
469
469
  Object.assign(messageParamsJson, {
470
470
  limited_time_offer: {
471
471
  text: message.offerText || LIBRARY_NAME,
472
- url: message.offerUrl || DONATE_URL, // Lia@Note 02-02-26 --- Apologies if this feels cheeky, just a fallback
472
+ url: message.offerUrl || DONATE_URL || undefined, // Vanz@Fix (bug 10): DONATE_URL now empty don't inject fallback link
473
473
  copy_code: message.offerCode,
474
474
  expiration_time: message.offerExpiration
475
475
  }
@@ -795,7 +795,16 @@ export const generateForwardMessageContent = (message, forceForward) => {
795
795
  content = normalizeMessageContent(content);
796
796
  content = proto.Message.decode(proto.Message.encode(content).finish());
797
797
  let key = Object.keys(content)[0];
798
- let score = content?.[key]?.contextInfo?.forwardingScore || 0;
798
+ // Vanz@Fix (bug 27): viewOnce/ephemeral messages wrap content in an outer key.
799
+ // Must unwrap first before reading forwardingScore, otherwise score stays 0.
800
+ let innerContent = content?.[key];
801
+ if (key === 'viewOnceMessage' || key === 'ephemeralMessage') {
802
+ const innerKey = innerContent?.message ? Object.keys(innerContent.message)[0] : null;
803
+ if (innerKey) {
804
+ innerContent = innerContent.message[innerKey];
805
+ }
806
+ }
807
+ let score = innerContent?.contextInfo?.forwardingScore || 0;
799
808
  score += message.key.fromMe && !forceForward ? 0 : 1;
800
809
  if (key === 'conversation') {
801
810
  content.extendedTextMessage = { text: content[key] };
@@ -944,7 +953,7 @@ export const generateWAMessageContent = async (message, options) => {
944
953
  else if (hasNonNullishProperty(message, 'groupInvite')) {
945
954
  m.groupInviteMessage = {};
946
955
  m.groupInviteMessage.inviteCode = message.groupInvite.inviteCode;
947
- m.groupInviteMessage.inviteExpiration = message.groupInvite.inviteExpiration;
956
+ m.groupInviteMessage.inviteExpiration = message.groupInvite.inviteExpiration ?? 0; // Vanz@Fix: default 0 (no expiry) instead of undefined
948
957
  m.groupInviteMessage.caption = message.groupInvite.text;
949
958
  m.groupInviteMessage.groupJid = message.groupInvite.jid;
950
959
  m.groupInviteMessage.groupName = message.groupInvite.subject;
@@ -956,7 +965,24 @@ export const generateWAMessageContent = async (message, options) => {
956
965
  const resp = await fetch(pfpUrl, { method: 'GET', dispatcher: options?.options?.dispatcher });
957
966
  if (resp.ok) {
958
967
  const buf = Buffer.from(await resp.arrayBuffer());
959
- m.groupInviteMessage.jpegThumbnail = buf;
968
+ // Vanz@Fix: upload thumbnail to WA server so thumbnailDirectPath/mediaKey are set properly
969
+ if (options.upload) {
970
+ try {
971
+ const uploaded = await prepareWAMessageMedia({ image: buf }, { upload: options.upload });
972
+ if (uploaded.imageMessage) {
973
+ m.groupInviteMessage.jpegThumbnail = buf;
974
+ m.groupInviteMessage.thumbnailDirectPath = uploaded.imageMessage.directPath;
975
+ m.groupInviteMessage.thumbnailSha256 = uploaded.imageMessage.fileSha256;
976
+ m.groupInviteMessage.thumbnailEncSha256 = uploaded.imageMessage.fileEncSha256;
977
+ m.groupInviteMessage.mediaKey = uploaded.imageMessage.mediaKey;
978
+ }
979
+ } catch {
980
+ // fallback: at least attach raw jpeg
981
+ m.groupInviteMessage.jpegThumbnail = buf;
982
+ }
983
+ } else {
984
+ m.groupInviteMessage.jpegThumbnail = buf;
985
+ }
960
986
  }
961
987
  }
962
988
  }
@@ -1363,10 +1389,6 @@ export const generateWAMessageContent = async (message, options) => {
1363
1389
  interactiveMessage.jpegThumbnail = message.thumbnail;
1364
1390
  }
1365
1391
  Object.assign(interactiveMessage.header, m);
1366
- // Vanzxy@Fix: hapus gifPlayback dari header biar bubble tidak miring ke kiri
1367
- if (interactiveMessage.header && interactiveMessage.header.videoMessage) {
1368
- delete interactiveMessage.header.videoMessage.gifPlayback;
1369
- }
1370
1392
  }
1371
1393
  if (hasOptionalProperty(message, 'audioFooter')) {
1372
1394
  const { audioMessage } = await prepareWAMessageMedia({
@@ -1429,6 +1451,11 @@ export const generateWAMessageContent = async (message, options) => {
1429
1451
  else if (hasOptionalProperty(card, 'footer')) {
1430
1452
  carouselCard.footer = { text: card.footer };
1431
1453
  }
1454
+ // Vanz@Fix (bug 20): add per-card contextInfo support
1455
+ // Allows each carousel card to have its own reply context, forward info, etc.
1456
+ if (hasNonNullishProperty(card, 'contextInfo')) {
1457
+ carouselCard.contextInfo = card.contextInfo;
1458
+ }
1432
1459
  return carouselCard;
1433
1460
  })),
1434
1461
  carouselCardType: CarouselCardType.UNKNOWN,
@@ -1502,7 +1529,7 @@ export const generateWAMessageContent = async (message, options) => {
1502
1529
  throw new Boom('Thumbnail must in buffer type', { statusCode: 400 });
1503
1530
  }
1504
1531
  if (!content.url || typeof content.url !== 'string') {
1505
- content.url = DONATE_URL; // Lia@Note 02-02-26 --- Apologies if this feels cheeky, just a fallback
1532
+ content.url = DONATE_URL || ''; // Vanz@Fix (bug 10): DONATE_URL now empty use empty string as safe fallback
1506
1533
  }
1507
1534
  const externalAdReply = {
1508
1535
  ...content,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vanzxy/baileys",
3
- "version": "1.3.0",
3
+ "version": "1.3.5",
4
4
  "description": "Enhanced Baileys fork by Vanzxy — based on @itsliaaa/baileys + @whiskeysockets/baileys with fixes for audio group status and clean media without newsletter button.",
5
5
  "main": "lib/index.js",
6
6
  "types": "lib/index.d.ts",