fix: skip retry for expired status messages over 24 hours old (#2280)

This commit is contained in:
João Lucas de Oliveira Lopes
2026-01-22 09:55:29 -03:00
committed by GitHub
parent 5cbad3170b
commit 92d4198ff1
2 changed files with 16 additions and 1 deletions
+3
View File
@@ -22,6 +22,9 @@ export const WA_ADV_HOSTED_DEVICE_SIG_PREFIX = Buffer.from([6, 6])
export const WA_DEFAULT_EPHEMERAL = 7 * 24 * 60 * 60
/** Status messages older than 24 hours are considered expired */
export const STATUS_EXPIRY_SECONDS = 24 * 60 * 60
export const NOISE_MODE = 'Noise_XX_25519_AESGCM_SHA256\0\0\0\0'
export const DICT_VERSION = 3
export const KEY_BUNDLE_TYPE = Buffer.from([5])
+13 -1
View File
@@ -3,7 +3,7 @@ import { Boom } from '@hapi/boom'
import { randomBytes } from 'crypto'
import Long from 'long'
import { proto } from '../../WAProto/index.js'
import { DEFAULT_CACHE_TTLS, KEY_BUNDLE_TYPE, MIN_PREKEY_COUNT } from '../Defaults'
import { DEFAULT_CACHE_TTLS, KEY_BUNDLE_TYPE, MIN_PREKEY_COUNT, STATUS_EXPIRY_SECONDS } from '../Defaults'
import type {
GroupParticipant,
MessageReceiptType,
@@ -1230,6 +1230,18 @@ export const makeMessagesRecvSocket = (config: SocketConfig) => {
return sendMessageAck(node)
}
// Skip retry for expired status messages (>24h old)
if (isJidStatusBroadcast(msg.key.remoteJid!)) {
const messageAge = unixTimestampSeconds() - toNumber(msg.messageTimestamp)
if (messageAge > STATUS_EXPIRY_SECONDS) {
logger.debug(
{ msgId: msg.key.id, messageAge, remoteJid: msg.key.remoteJid },
'skipping retry for expired status message'
)
return sendMessageAck(node)
}
}
const errorMessage = msg?.messageStubParameters?.[0] || ''
const isPreKeyError = errorMessage.includes('PreKey')