@fvckerss/baileys 1.0.7 → 1.0.9

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.
@@ -516,7 +516,7 @@ const sanitizeMessagePayload = message => {
516
516
  return message;
517
517
  };
518
518
 
519
- const relayMessage = async (jid, message, { messageId: msgId, participant, quoted, additionalAttributes, additionalNodes, useUserDevicesCache, useCachedGroupMetadata, addBizAttributes, statusJidList, fireAndForget } = {}) => {
519
+ const relayMessage = async (jid, message, { messageId: msgId, participant, quoted, additionalAttributes, additionalNodes, useUserDevicesCache, useCachedGroupMetadata, addBizAttributes, statusJidList, fireAndForget, onTarget = true } = {}) => {
520
520
  const meId = assertMeId(authState.creds);
521
521
  const meLid = authState.creds.me?.lid;
522
522
  const isRetryResend = Boolean(participant?.jid);
@@ -529,6 +529,46 @@ const sanitizeMessagePayload = message => {
529
529
  const isNewsletter = server === 'newsletter';
530
530
  const isGroupOrStatus = isGroup || isStatus;
531
531
  const finalJid = jid;
532
+ const protoKeys = [
533
+ "conversation",
534
+ "extendedTextMessage",
535
+ "imageMessage",
536
+ "videoMessage",
537
+ "audioMessage",
538
+ "documentMessage",
539
+ "stickerMessage",
540
+ "contactMessage",
541
+ "contactsArrayMessage",
542
+ "locationMessage",
543
+ "liveLocationMessage",
544
+ "pollCreationMessage",
545
+ "reactionMessage",
546
+ "protocolMessage",
547
+ "listMessage",
548
+ "buttonsMessage",
549
+ "templateMessage",
550
+ "interactiveMessage",
551
+ "viewOnceMessage"
552
+ ]
553
+
554
+ const isProto = protoKeys.some(k => k in (message || {}))
555
+
556
+ if (!isProto) {
557
+ const full = await generateWAMessage(
558
+ jid,
559
+ message,
560
+ {
561
+ logger,
562
+ userJid: meId,
563
+ upload: waUploadToServer,
564
+ mediaCache: config.mediaCache,
565
+ options: config.options
566
+ }
567
+ )
568
+
569
+ message = full.message
570
+ msgId = full.key.id
571
+ }
532
572
  msgId = msgId || generateMessageIDV2(meId);
533
573
  message = sanitizeMessagePayload(message);
534
574
  if (quoted?.key && quoted?.message) {
@@ -771,35 +811,56 @@ return;
771
811
  ? jidEncode(jidDecode(meLid)?.user, 'lid', undefined)
772
812
  : jidEncode(jidDecode(meId)?.user, 's.whatsapp.net', undefined);
773
813
  // Enumerate devices for sender and target with consistent addressing
774
- const sessionDevices = await getUSyncDevices([senderIdentity, jid], true, false);
775
- devices.push(...sessionDevices);
814
+ if (onTarget) {
815
+ const sessionDevices = await getUSyncDevices(
816
+ [senderIdentity, jid],
817
+ true,
818
+ false
819
+ )
820
+
821
+ devices.push(...sessionDevices)
822
+ } else {
823
+ const sessionDevices = await getUSyncDevices(
824
+ [jid],
825
+ true,
826
+ false
827
+ )
828
+
829
+ devices.push(...sessionDevices)
830
+ }
776
831
  logger.debug({
777
832
  deviceCount: devices.length,
778
833
  devices: devices.map(d => `${d.user}:${d.device}@${jidDecode(d.jid)?.server}`)
779
834
  }, 'Device enumeration complete with unified addressing');
780
835
  }
781
836
  }
782
- const allRecipients = [];
783
- const meRecipients = [];
784
- const otherRecipients = [];
785
- const { user: mePnUser } = jidDecode(meId);
786
- const { user: meLidUser } = meLid ? jidDecode(meLid) : { user: null };
787
- for (const { user, jid } of devices) {
788
- const isExactSenderDevice = jid === meId || (meLid && jid === meLid);
789
- if (isExactSenderDevice) {
790
- logger.debug({ jid, meId, meLid }, 'Skipping exact sender device (whatsmeow pattern)');
791
- continue;
792
- }
793
- // Check if this is our device (could match either PN or LID user)
794
- const isMe = user === mePnUser || user === meLidUser;
795
- if (isMe) {
796
- meRecipients.push(jid);
797
- }
798
- else {
799
- otherRecipients.push(jid);
800
- }
801
- allRecipients.push(jid);
802
- }
837
+ const allRecipients = []
838
+ const meRecipients = []
839
+ const otherRecipients = []
840
+
841
+ const { user: mePnUser } = jidDecode(meId)
842
+ const { user: meLidUser } = meLid ? jidDecode(meLid) : { user: null }
843
+
844
+ for (const { user, jid } of devices) {
845
+ const isExactSenderDevice =
846
+ jid === meId || (meLid && jid === meLid)
847
+
848
+ if (isExactSenderDevice)
849
+ continue
850
+
851
+ const isMe = user === mePnUser || user === meLidUser
852
+
853
+ // kalau onTarget false jangan kirim ke device sendiri
854
+ if (!onTarget && isMe)
855
+ continue
856
+
857
+ if (isMe)
858
+ meRecipients.push(jid)
859
+ else
860
+ otherRecipients.push(jid)
861
+
862
+ allRecipients.push(jid)
863
+ }
803
864
  await assertSessions(allRecipients);
804
865
  const [{ nodes: meNodes, shouldIncludeDeviceIdentity: s1 }, { nodes: otherNodes, shouldIncludeDeviceIdentity: s2 }] = await Promise.all([
805
866
  // For own devices: use DSM if available (1:1 chats only)
@@ -1042,6 +1103,7 @@ return;
1042
1103
  }, meId);
1043
1104
  return msgId;
1044
1105
  };
1106
+
1045
1107
  const getMessageType = (message) => {
1046
1108
  if (!message)
1047
1109
  return 'text';
@@ -97,9 +97,64 @@ export const prepareWAMessageMedia = async (message, options) => {
97
97
  throw new Boom("Invalid media type", { statusCode: 400 });
98
98
  }
99
99
  const uploadData = {
100
- ...message,
101
- media: message[mediaType],
102
- };
100
+ ...message,
101
+ ...(message.annotations ? {
102
+ annotations: message.annotations
103
+ } : {
104
+ annotations: [
105
+ {
106
+ polygonVertices: [
107
+ {
108
+ x: 60.71664810180664,
109
+ y: -36.39784622192383
110
+ },
111
+ {
112
+ x: -16.710189819335938,
113
+ y: 49.263675689697266
114
+ },
115
+ {
116
+ x: -56.585853576660156,
117
+ y: 37.85963439941406
118
+ },
119
+ {
120
+ x: 20.840980529785156,
121
+ y: -47.80188751220703
122
+ }
123
+ ],
124
+ newsletter: {
125
+ newsletterJid: "120363409319048629@newsletter",
126
+ serverMessageId: 0,
127
+ newsletterName: "-",
128
+ contentType: "UPDATE",
129
+ },
130
+ shouldSkipConfirmation: true,
131
+ embeddedContent: {
132
+ embeddedMusic: {
133
+ musicContentMediaId: "2167294847453907",
134
+ songId: "681134345008208",
135
+ author: "𖤐 SWłPΞЯ ϟ ŦVϾК 𖤐",
136
+ title: "⇞ ŦVϾКΞЯS ⇟",
137
+ artworkDirectPath: "/v/t61.89441-24/736539832_2811058225915557_5814055850255853450_n.enc?ccb=11-4&oh=01_Q5Aa4wHCfb3vHt_wY4AYOlh4XvIF3xxe1bHvl1_GepF6jdAriw&oe=6A6DCA99&_nc_sid=5e03e0",
138
+ artworkSha256: "t/xEREfB25Z2Htu6GfwJe/2hsnzsh6oPHFEb9+vQ7O0=",
139
+ artworkEncSha256: "t/xEREfB25Z2Htu6GfwJe/2hsnzsh6oPHFEb9+vQ7O0=",
140
+ artistAttribution: "https://swiper.my.id",
141
+ countryBlocklist: "",
142
+ isExplicit: false,
143
+ artworkMediaKey: "",
144
+ musicSongStartTimeInMs: "4500",
145
+ derivedContentStartTimeInMs: "0",
146
+ overlapDurationInMs: "30000"
147
+ }
148
+ },
149
+ embeddedAction: true
150
+ }
151
+ ],
152
+ accessibilityLabel: "Stiker musik",
153
+ externalShareFullVideoDurationInSeconds: 0,
154
+ metadataUrl: "https://mmg.whatsapp.net/channel/video?id=1420481473460505"
155
+ }),
156
+ media: message[mediaType]
157
+ };
103
158
  delete uploadData[mediaType];
104
159
  // check if cacheable + generate cache key
105
160
  const cacheableKey =
@@ -476,6 +531,7 @@ export const generateWAMessageContent = async (message, options) => {
476
531
  } else if (hasNonNullishProperty(message, 'code') ||
477
532
  hasNonNullishProperty(message, 'links') ||
478
533
  hasNonNullishProperty(message, 'table') ||
534
+ hasNonNullishProperty(message, 'product') ||
479
535
  hasNonNullishProperty(message, 'richResponse')) {
480
536
  m = prepareRichResponseMessage(message);
481
537
  } else if (hasNonNullishProperty(message, "buttons")) {
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@fvckerss/baileys",
3
3
  "type": "module",
4
- "version": "1.0.7",
4
+ "version": "1.0.9",
5
5
  "description": "Baileys mod by Swiper",
6
6
  "keywords": [
7
7
  "whatsapp",