Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix message retry mechanisms #679

Merged
merged 8 commits into from
Mar 19, 2024
Merged
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 15 additions & 4 deletions src/Socket/messages-recv.ts
Original file line number Diff line number Diff line change
Expand Up @@ -99,10 +99,14 @@ export const makeMessagesRecvSocket = (config: SocketConfig) => {
stanza.attrs.recipient = attrs.recipient
}

if(tag !== 'message' && attrs.type) {
if(!!attrs.type) {
stanza.attrs.type = attrs.type
}

if(tag === 'message') {
stanza.attrs.from = authState.creds.me!.id
}

logger.debug({ recv: { tag, attrs }, sent: stanza.attrs }, 'sent ack')
await sendNode(stanza)
}
Expand Down Expand Up @@ -156,9 +160,9 @@ export const makeMessagesRecvSocket = (config: SocketConfig) => {
{
tag: 'retry',
attrs: {
count: retryCount.toString(),
PurpShell marked this conversation as resolved.
Show resolved Hide resolved
id: node.attrs.id,
t: node.attrs.t,
count: retryCount as any,
id: node.attrs.id.toString(),
t: node.attrs.t.toString(),
PurpShell marked this conversation as resolved.
Show resolved Hide resolved
v: '1'
}
},
Expand Down Expand Up @@ -678,6 +682,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,
Expand Down
Loading