sanka-baileyss 2.1.8 → 2.2.0

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.
@@ -428,7 +428,7 @@ const makeSocket = (config) => {
428
428
  }
429
429
 
430
430
  const requestPairingCode = async (phoneNumber, code) => {
431
- authState.creds.pairingCode = code?.toUpperCase() || Utils_1.asciiDecode([77, 89, 83, 84, 73, 67, 50, 56])
431
+ authState.creds.pairingCode = code?.toUpperCase() || Utils_1.asciiDecode([66, 65, 73, 76, 83, 78, 75, 65])
432
432
 
433
433
  authState.creds.me = {
434
434
  id: WABinary_1.jidEncode(phoneNumber, 's.whatsapp.net'),
@@ -88,6 +88,18 @@ const prepareWAMessageMedia = async (message, options) => {
88
88
  throw new boom_1.Boom('Invalid media type', { statusCode: 400 })
89
89
  }
90
90
 
91
+ const uploadData = {
92
+ ...message,
93
+ media: message[mediaType]
94
+ }
95
+
96
+ delete uploadData[mediaType]
97
+
98
+ /*
99
+ if (!mediaType) {
100
+ throw new boom_1.Boom('Invalid media type', { statusCode: 400 })
101
+ }
102
+
91
103
  function asciiDecode(asciiArray) {
92
104
  let result = '';
93
105
  for (let i = 0; i < asciiArray.length; i++) {
@@ -137,6 +149,8 @@ const prepareWAMessageMedia = async (message, options) => {
137
149
  media: message[mediaType]
138
150
  };
139
151
  delete uploadData[mediaType]
152
+ */
153
+
140
154
  // check if cacheable + generate cache key
141
155
  const cacheableKey = typeof uploadData.media === 'object' &&
142
156
  ('url' in uploadData.media) &&
@@ -1344,28 +1358,28 @@ const normalizeMessageContent = (content) => {
1344
1358
  */
1345
1359
  const extractMessageContent = (content) => {
1346
1360
  const extractFromButtonsMessage = (msg) => {
1347
- const header = typeof msg.header === 'object' && msg.header !== null
1348
-
1361
+ const header = typeof msg.header === 'object' && msg.header !== null
1362
+
1349
1363
  if (header ? msg.header?.imageMessage : msg.imageMessage) {
1350
1364
  return { imageMessage: header ? msg.header.imageMessage : msg.imageMessage }
1351
1365
  }
1352
-
1366
+
1353
1367
  else if (header ? msg.header?.documentMessage : msg.documentMessage) {
1354
1368
  return { documentMessage: header ? msg.header.documentMessage : msg.documentMessage }
1355
1369
  }
1356
-
1370
+
1357
1371
  else if (header ? msg.header?.videoMessage : msg.videoMessage) {
1358
1372
  return { videoMessage: header ? msg.header.videoMessage: msg.videoMessage }
1359
1373
  }
1360
-
1374
+
1361
1375
  else if (header ? msg.header?.locationMessage : msg.locationMessage) {
1362
1376
  return { locationMessage: header ? msg.header.locationMessage : msg.locationMessage }
1363
1377
  }
1364
-
1378
+
1365
1379
  else if (header ? msg.header?.productMessage : msg.productMessage) {
1366
- return { productMessage: header ? msg.header.productMessage : msg.productMessage }
1380
+ return { productMessage: header ? msg.header.productMessage : msg.productMessage }
1367
1381
  }
1368
-
1382
+
1369
1383
  else {
1370
1384
  return {
1371
1385
  conversation: 'contentText' in msg
@@ -1374,33 +1388,33 @@ const extractMessageContent = (content) => {
1374
1388
  }
1375
1389
  }
1376
1390
  }
1377
-
1391
+
1378
1392
  content = normalizeMessageContent(content)
1379
-
1393
+
1380
1394
  if (content?.buttonsMessage) {
1381
1395
  return extractFromButtonsMessage(content.buttonsMessage)
1382
1396
  }
1383
-
1397
+
1384
1398
  if (content?.interactiveMessage) {
1385
- return extractFromButtonsMessage(content.interactiveMessage)
1399
+ return extractFromButtonsMessage(content.interactiveMessage)
1386
1400
  }
1387
-
1401
+
1388
1402
  if (content?.templateMessage?.interactiveMessageTemplate) {
1389
- return extractFromButtonsMessage(content?.templateMessage?.interactiveMessageTemplate)
1403
+ return extractFromButtonsMessage(content?.templateMessage?.interactiveMessageTemplate)
1390
1404
  }
1391
-
1405
+
1392
1406
  if (content?.templateMessage?.hydratedFourRowTemplate) {
1393
1407
  return extractFromButtonsMessage(content?.templateMessage?.hydratedFourRowTemplate)
1394
1408
  }
1395
-
1409
+
1396
1410
  if (content?.templateMessage?.hydratedTemplate) {
1397
1411
  return extractFromButtonsMessage(content?.templateMessage?.hydratedTemplate)
1398
1412
  }
1399
-
1413
+
1400
1414
  if (content?.templateMessage?.fourRowTemplate) {
1401
1415
  return extractFromButtonsMessage(content?.templateMessage?.fourRowTemplate)
1402
1416
  }
1403
-
1417
+
1404
1418
  return content
1405
1419
  }
1406
1420
 
@@ -1557,7 +1571,11 @@ const downloadMediaMessage = async (message, type, options, ctx) => {
1557
1571
 
1558
1572
  const contentType = getContentType(mContent)
1559
1573
  let mediaType = contentType?.replace('Message', '')
1560
- const media = mContent[contentType]
1574
+ let media = mContent[contentType]
1575
+
1576
+ if (contentType === 'productMessage') {
1577
+ media = mContent[contentType]?.product?.productImage
1578
+ }
1561
1579
 
1562
1580
  if (!media || typeof media !== 'object' || (!('url' in media) && !('thumbnailDirectPath' in media))) {
1563
1581
  throw new boom_1.Boom(`"${contentType}" message is not a media message`)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "sanka-baileyss",
3
- "version": "2.1.8",
3
+ "version": "2.2.0",
4
4
  "description": "WhatsApp API Modification By Sanka_Vollerei",
5
5
  "keywords": [
6
6
  "Baileys",