mirror of
https://github.com/FranP-code/Baileys.git
synced 2025-10-13 00:32:22 +00:00
refactor: message decoding
1. removes redundant receipt (was exactly the same as delivery receipt without the timestamp) 2. decodeWAMessage now returns a proper message struct 3. each message stanza results in exactly one message decoded
This commit is contained in:
@@ -73,7 +73,10 @@ export const makeMessagesSocket = (config: SocketConfig) => {
|
||||
}
|
||||
return mediaConn
|
||||
}
|
||||
|
||||
/**
|
||||
* generic send receipt function
|
||||
* used for receipts of phone call, read, delivery etc.
|
||||
* */
|
||||
const sendReceipt = async(jid: string, participant: string | undefined, messageIds: string[], type: 'read' | 'read-self' | undefined) => {
|
||||
const node: BinaryNode = {
|
||||
tag: 'receipt',
|
||||
@@ -107,10 +110,6 @@ export const makeMessagesSocket = (config: SocketConfig) => {
|
||||
await sendNode(node)
|
||||
}
|
||||
|
||||
const sendDeliveryReceipt = (jid: string, participant: string | undefined, messageIds: string[]) => {
|
||||
return sendReceipt(jid, participant, messageIds, undefined)
|
||||
}
|
||||
|
||||
const sendReadReceipt = async(jid: string, participant: string | undefined, messageIds: string[]) => {
|
||||
const privacySettings = await fetchPrivacySettings()
|
||||
// based on privacy settings, we have to change the read type
|
||||
@@ -424,7 +423,7 @@ export const makeMessagesSocket = (config: SocketConfig) => {
|
||||
...sock,
|
||||
assertSessions,
|
||||
relayMessage,
|
||||
sendDeliveryReceipt,
|
||||
sendReceipt,
|
||||
sendReadReceipt,
|
||||
refreshMediaConn,
|
||||
waUploadToServer,
|
||||
|
||||
Reference in New Issue
Block a user