mirror of
https://github.com/FranP-code/Baileys.git
synced 2025-10-13 00:32:22 +00:00
Merge pull request #679 from WhiskeySockets/fix-missing-messages
Fix message retry mechanisms
This commit is contained in:
@@ -81,7 +81,7 @@ export const makeMessagesRecvSocket = (config: SocketConfig) => {
|
|||||||
|
|
||||||
let sendActiveReceipts = false
|
let sendActiveReceipts = false
|
||||||
|
|
||||||
const sendMessageAck = async({ tag, attrs }: BinaryNode) => {
|
const sendMessageAck = async({ tag, attrs, content }: BinaryNode) => {
|
||||||
const stanza: BinaryNode = {
|
const stanza: BinaryNode = {
|
||||||
tag: 'ack',
|
tag: 'ack',
|
||||||
attrs: {
|
attrs: {
|
||||||
@@ -99,9 +99,14 @@ export const makeMessagesRecvSocket = (config: SocketConfig) => {
|
|||||||
stanza.attrs.recipient = attrs.recipient
|
stanza.attrs.recipient = attrs.recipient
|
||||||
}
|
}
|
||||||
|
|
||||||
if(tag !== 'message' && attrs.type) {
|
|
||||||
stanza.attrs.type = attrs.type
|
if(!!attrs.type && (tag !== 'message' || getBinaryNodeChild({ tag, attrs, content }, 'unavailable'))) {
|
||||||
}
|
stanza.attrs.type = attrs.type
|
||||||
|
}
|
||||||
|
|
||||||
|
if(tag === 'message' && getBinaryNodeChild({ tag, attrs, content }, 'unavailable')) {
|
||||||
|
stanza.attrs.from = authState.creds.me!.id
|
||||||
|
}
|
||||||
|
|
||||||
logger.debug({ recv: { tag, attrs }, sent: stanza.attrs }, 'sent ack')
|
logger.debug({ recv: { tag, attrs }, sent: stanza.attrs }, 'sent ack')
|
||||||
await sendNode(stanza)
|
await sendNode(stanza)
|
||||||
@@ -678,6 +683,13 @@ export const makeMessagesRecvSocket = (config: SocketConfig) => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const handleMessage = async(node: BinaryNode) => {
|
const handleMessage = async(node: BinaryNode) => {
|
||||||
|
if(getBinaryNodeChild(node, 'unavailable') && !getBinaryNodeChild(node, 'enc')) {
|
||||||
|
// "missing message from node" fix
|
||||||
|
logger.debug(node, 'missing body; sending ack then ignoring.')
|
||||||
|
await sendMessageAck(node)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
const { fullMessage: msg, category, author, decrypt } = decryptMessageNode(
|
const { fullMessage: msg, category, author, decrypt } = decryptMessageNode(
|
||||||
node,
|
node,
|
||||||
authState.creds.me!.id,
|
authState.creds.me!.id,
|
||||||
|
|||||||
Reference in New Issue
Block a user