moved retryCount before validating the session (#2167)
This commit is contained in:
@@ -431,12 +431,12 @@ export const makeMessagesRecvSocket = (config: SocketConfig) => {
|
||||
let shouldRecreateSession = false
|
||||
let recreateReason = ''
|
||||
|
||||
if (enableAutoSessionRecreation && messageRetryManager) {
|
||||
if (enableAutoSessionRecreation && messageRetryManager && retryCount > 1) {
|
||||
try {
|
||||
// Check if we have a session with this JID
|
||||
const sessionId = signalRepository.jidToSignalProtocolAddress(fromJid)
|
||||
const hasSession = await signalRepository.validateSession(fromJid)
|
||||
const result = messageRetryManager.shouldRecreateSession(fromJid, retryCount, hasSession.exists)
|
||||
const result = messageRetryManager.shouldRecreateSession(fromJid, hasSession.exists)
|
||||
shouldRecreateSession = result.recreate
|
||||
recreateReason = result.reason
|
||||
|
||||
@@ -989,12 +989,12 @@ export const makeMessagesRecvSocket = (config: SocketConfig) => {
|
||||
let shouldRecreateSession = false
|
||||
let recreateReason = ''
|
||||
|
||||
if (enableAutoSessionRecreation && messageRetryManager) {
|
||||
if (enableAutoSessionRecreation && messageRetryManager && retryCount > 1) {
|
||||
try {
|
||||
const sessionId = signalRepository.jidToSignalProtocolAddress(participant)
|
||||
|
||||
const hasSession = await signalRepository.validateSession(participant)
|
||||
const result = messageRetryManager.shouldRecreateSession(participant, retryCount, hasSession.exists)
|
||||
const result = messageRetryManager.shouldRecreateSession(participant, hasSession.exists)
|
||||
shouldRecreateSession = result.recreate
|
||||
recreateReason = result.reason
|
||||
|
||||
@@ -1179,7 +1179,7 @@ export const makeMessagesRecvSocket = (config: SocketConfig) => {
|
||||
|
||||
const encNode = getBinaryNodeChild(node, 'enc')
|
||||
// TODO: temporary fix for crashes and issues resulting of failed msmsg decryption
|
||||
if (encNode && encNode.attrs.type === 'msmsg') {
|
||||
if (encNode?.attrs.type === 'msmsg') {
|
||||
logger.debug({ key: node.attrs.key }, 'ignored msmsg')
|
||||
await sendMessageAck(node, NACK_REASONS.MissingMessageSecret)
|
||||
return
|
||||
|
||||
@@ -109,7 +109,7 @@ export class MessageRetryManager {
|
||||
/**
|
||||
* Check if a session should be recreated based on retry count and history
|
||||
*/
|
||||
shouldRecreateSession(jid: string, retryCount: number, hasSession: boolean): { reason: string; recreate: boolean } {
|
||||
shouldRecreateSession(jid: string, hasSession: boolean): { reason: string; recreate: boolean } {
|
||||
// If we don't have a session, always recreate
|
||||
if (!hasSession) {
|
||||
this.sessionRecreateHistory.set(jid, Date.now())
|
||||
@@ -120,11 +120,6 @@ export class MessageRetryManager {
|
||||
}
|
||||
}
|
||||
|
||||
// Only consider recreation if retry count > 1
|
||||
if (retryCount < 2) {
|
||||
return { reason: '', recreate: false }
|
||||
}
|
||||
|
||||
const now = Date.now()
|
||||
const prevTime = this.sessionRecreateHistory.get(jid)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user