refactor(retry): improve message encryption and retry logic (#2055)

This commit is contained in:
vini
2025-11-19 10:13:51 -03:00
committed by GitHub
parent 9b012baa5c
commit b4863b624e
4 changed files with 66 additions and 50 deletions
+6 -1
View File
@@ -206,6 +206,7 @@ export function decodeMessageNode(stanza: BinaryNode, meId: string, meLid: strin
const fullMessage: WAMessage = {
key,
category: stanza.attrs.category,
messageTimestamp: +stanza.attrs.t!,
pushName: pushname,
broadcast: isJidBroadcast(from)
@@ -248,6 +249,10 @@ export const decryptMessageNode = (
fullMessage.key.isViewOnce = true // TODO: remove from here and add a STUB TYPE
}
if (attrs.count && tag === 'enc') {
fullMessage.retryCount = Number(attrs.count)
}
if (tag !== 'enc' && tag !== 'plaintext') {
continue
}
@@ -333,7 +338,7 @@ export const decryptMessageNode = (
}
// if nothing was found to decrypt
if (!decryptables) {
if (!decryptables && !fullMessage.key?.isViewOnce) {
fullMessage.messageStubType = proto.WebMessageInfo.StubType.CIPHERTEXT
fullMessage.messageStubParameters = [NO_MESSAGE_FOUND_ERROR_TEXT]
}