feat: Add max msg retry count (#572)

This commit is contained in:
Alex Sandro
2024-01-19 13:01:20 -03:00
committed by GitHub
parent d08b2e8d48
commit 18990f874f
4 changed files with 8 additions and 2 deletions

View File

@@ -45,6 +45,7 @@ export const makeMessagesRecvSocket = (config: SocketConfig) => {
const {
logger,
retryRequestDelayMs,
maxMsgRetryCount,
getMessage,
shouldIgnoreJid
} = config
@@ -130,7 +131,7 @@ export const makeMessagesRecvSocket = (config: SocketConfig) => {
const msgId = node.attrs.id
let retryCount = msgRetryCache.get<number>(msgId) || 0
if(retryCount >= 5) {
if(retryCount >= maxMsgRetryCount) {
logger.debug({ retryCount, msgId }, 'reached retry limit, clearing')
msgRetryCache.del(msgId)
return
@@ -503,7 +504,7 @@ export const makeMessagesRecvSocket = (config: SocketConfig) => {
const willSendMessageAgain = (id: string, participant: string) => {
const key = `${id}:${participant}`
const retryCount = msgRetryCache.get<number>(key) || 0
return retryCount < 5
return retryCount < maxMsgRetryCount
}
const updateSendMessageAgainCount = (id: string, participant: string) => {