Merge pull request #679 from WhiskeySockets/fix-missing-messages

Fix message retry mechanisms
This commit is contained in:
Alessandro Autiero
2024-03-19 22:27:22 +01:00
committed by GitHub

View File

@@ -81,7 +81,7 @@ export const makeMessagesRecvSocket = (config: SocketConfig) => {
let sendActiveReceipts = false
const sendMessageAck = async({ tag, attrs }: BinaryNode) => {
const sendMessageAck = async({ tag, attrs, content }: BinaryNode) => {
const stanza: BinaryNode = {
tag: 'ack',
attrs: {
@@ -99,9 +99,14 @@ export const makeMessagesRecvSocket = (config: SocketConfig) => {
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')
await sendNode(stanza)
@@ -678,6 +683,13 @@ export const makeMessagesRecvSocket = (config: SocketConfig) => {
}
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(
node,
authState.creds.me!.id,