@pontasockets/baileys 1.0.2 → 1.0.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.
package/README.md
CHANGED
|
@@ -242,6 +242,27 @@ sock.sendMessage(jid, content, options?)
|
|
|
242
242
|
|
|
243
243
|
#### Standard Messages
|
|
244
244
|
|
|
245
|
+
<details>
|
|
246
|
+
<summary><b>📦 Sticker Pack</b></summary>
|
|
247
|
+
<br>
|
|
248
|
+
|
|
249
|
+
```js
|
|
250
|
+
sock.sendMessage(jid, {
|
|
251
|
+
stickerPack: {
|
|
252
|
+
name: 'Koleksi Ponta',
|
|
253
|
+
publisher: 'PontaCT',
|
|
254
|
+
description: 'Sticker pack pertama',
|
|
255
|
+
cover: { url: 'https://example.jpg' },
|
|
256
|
+
stickers: [
|
|
257
|
+
{ sticker: { url: 'https://example.webp' }, emojis: ['😂'] },
|
|
258
|
+
{ sticker: { url: 'https://example.webp' }, emojis: ['🔥'] }
|
|
259
|
+
]
|
|
260
|
+
}
|
|
261
|
+
})
|
|
262
|
+
```
|
|
263
|
+
|
|
264
|
+
</details>
|
|
265
|
+
|
|
245
266
|
<details>
|
|
246
267
|
<summary><b>📝 Text Message</b></summary>
|
|
247
268
|
<br>
|
|
@@ -681,7 +681,17 @@ const makeMessagesRecvSocket = (config) => {
|
|
|
681
681
|
|
|
682
682
|
const handleMexNotification = (id, node) => {
|
|
683
683
|
const operation = node?.attrs?.op_name
|
|
684
|
-
|
|
684
|
+
let content
|
|
685
|
+
try {
|
|
686
|
+
content = JSON.parse(node?.content)
|
|
687
|
+
} catch (parseErr) {
|
|
688
|
+
logger.debug({ parseErr, node }, 'failed to parse mex notification content, skipping')
|
|
689
|
+
return
|
|
690
|
+
}
|
|
691
|
+
if (!content?.data) {
|
|
692
|
+
logger.debug({ operation, node }, 'mex notification missing content.data, skipping')
|
|
693
|
+
return
|
|
694
|
+
}
|
|
685
695
|
|
|
686
696
|
let contentPath
|
|
687
697
|
let action
|
|
@@ -723,6 +733,17 @@ const makeMessagesRecvSocket = (config) => {
|
|
|
723
733
|
contentPath = content.data[Types_1.XWAPaths.DEMOTE]
|
|
724
734
|
}
|
|
725
735
|
|
|
736
|
+
// FIX: sebelumnya contentPath.actor.pn diakses langsung tanpa cek dulu.
|
|
737
|
+
// Kalau operation-nya bukan promote/demote yang beneran (WA ngirim tipe
|
|
738
|
+
// operasi MEX baru yang belum dikenal library ini), content.data[path]
|
|
739
|
+
// bisa undefined, dan ini crash dengan "Cannot read properties of
|
|
740
|
+
// undefined (reading 'actor')". Sekarang di-skip aja kalau gak lengkap,
|
|
741
|
+
// gak bikin seluruh proses notification gagal.
|
|
742
|
+
if (!contentPath || !contentPath.actor || !contentPath.user) {
|
|
743
|
+
logger.debug({ operation, node }, 'unhandled/incomplete mex notification, skipping')
|
|
744
|
+
return
|
|
745
|
+
}
|
|
746
|
+
|
|
726
747
|
ev.emit('newsletter-participants.update', {
|
|
727
748
|
id,
|
|
728
749
|
author: contentPath.actor.pn,
|
|
@@ -1252,7 +1273,7 @@ const makeMessagesRecvSocket = (config) => {
|
|
|
1252
1273
|
try {
|
|
1253
1274
|
key = Utils_1.decodeMessageNode(node, authState.creds.me.id, authState.creds.me.lid || '').fullMessage.key
|
|
1254
1275
|
} catch (error) {
|
|
1255
|
-
logger.error({ error, node }, 'failed to decode unavailable message node, skipping placeholder resend')
|
|
1276
|
+
logger.error({ err: error, node }, 'failed to decode unavailable message node, skipping placeholder resend')
|
|
1256
1277
|
return
|
|
1257
1278
|
}
|
|
1258
1279
|
response = await requestPlaceholderResend(key);
|
|
@@ -1275,11 +1296,11 @@ const makeMessagesRecvSocket = (config) => {
|
|
|
1275
1296
|
// (live message) maupun lewat offline queue.
|
|
1276
1297
|
decodeResult = Utils_1.decryptMessageNode(node, authState.creds.me.id, authState.creds.me.lid || '', signalRepository, logger)
|
|
1277
1298
|
} catch (error) {
|
|
1278
|
-
logger.error({ error, node }, 'failed to decrypt/decode message node, dropping')
|
|
1299
|
+
logger.error({ err: error, node }, 'failed to decrypt/decode message node, dropping')
|
|
1279
1300
|
try {
|
|
1280
1301
|
await sendMessageAck(node, Utils_1.NACK_REASONS.ParsingError)
|
|
1281
1302
|
} catch (ackError) {
|
|
1282
|
-
logger.error({ ackError }, 'failed to ack undecodable message node')
|
|
1303
|
+
logger.error({ err: ackError }, 'failed to ack undecodable message node')
|
|
1283
1304
|
}
|
|
1284
1305
|
return
|
|
1285
1306
|
}
|
|
@@ -1358,7 +1379,7 @@ const makeMessagesRecvSocket = (config) => {
|
|
|
1358
1379
|
await Utils_1.delay(1000)
|
|
1359
1380
|
} catch (uploadErr) {
|
|
1360
1381
|
logger.error({
|
|
1361
|
-
uploadErr
|
|
1382
|
+
err: uploadErr
|
|
1362
1383
|
}, 'Pre-key upload failed, proceeding with retry anyway')
|
|
1363
1384
|
}
|
|
1364
1385
|
}
|
|
@@ -1378,12 +1399,12 @@ const makeMessagesRecvSocket = (config) => {
|
|
|
1378
1399
|
await sendRetryRequest(node, !encNode)
|
|
1379
1400
|
} catch (retryErr) {
|
|
1380
1401
|
logger.error({
|
|
1381
|
-
retryErr
|
|
1402
|
+
err: retryErr
|
|
1382
1403
|
}, 'Failed to send retry after error handling')
|
|
1383
1404
|
}
|
|
1384
1405
|
}
|
|
1385
1406
|
}).catch((mutexErr) => {
|
|
1386
|
-
logger.error({ mutexErr }, 'retryMutex task failed unexpectedly')
|
|
1407
|
+
logger.error({ err: mutexErr }, 'retryMutex task failed unexpectedly')
|
|
1387
1408
|
})
|
|
1388
1409
|
} else {
|
|
1389
1410
|
let type = undefined
|
|
@@ -1529,7 +1550,7 @@ const makeMessagesRecvSocket = (config) => {
|
|
|
1529
1550
|
])
|
|
1530
1551
|
} catch (error) {
|
|
1531
1552
|
logger.error({
|
|
1532
|
-
error,
|
|
1553
|
+
err: error,
|
|
1533
1554
|
node
|
|
1534
1555
|
}, 'error in handling message')
|
|
1535
1556
|
// Kalau exception terjadi sebelum sempat ack (misal error di plugin/group
|
|
@@ -1538,7 +1559,7 @@ const makeMessagesRecvSocket = (config) => {
|
|
|
1538
1559
|
try {
|
|
1539
1560
|
await sendMessageAck(node, Utils_1.NACK_REASONS.UnhandledError)
|
|
1540
1561
|
} catch (ackError) {
|
|
1541
|
-
logger.error({ ackError }, 'failed to ack message after error')
|
|
1562
|
+
logger.error({ err: ackError }, 'failed to ack message after error')
|
|
1542
1563
|
}
|
|
1543
1564
|
}
|
|
1544
1565
|
}
|
|
@@ -202,7 +202,7 @@ const processMessage = async (message, { shouldProcessHistoryMsg, placeholderRes
|
|
|
202
202
|
case WAProto_1.proto.Message.ProtocolMessage.Type.PEER_DATA_OPERATION_REQUEST_RESPONSE_MESSAGE:
|
|
203
203
|
const response = protocolMsg.peerDataOperationRequestResponseMessage
|
|
204
204
|
if (response) {
|
|
205
|
-
await
|
|
205
|
+
await placeholderResendCache?.del(response.stanzaId)
|
|
206
206
|
// TODO: IMPLEMENT HISTORY SYNC ETC (sticker uploads etc.).
|
|
207
207
|
const { peerDataOperationResult } = response
|
|
208
208
|
for (const result of peerDataOperationResult) {
|
|
@@ -423,4 +423,4 @@ module.exports = {
|
|
|
423
423
|
getChatId,
|
|
424
424
|
decryptPollVote,
|
|
425
425
|
processMessage
|
|
426
|
-
}
|
|
426
|
+
}
|