mirror of
https://github.com/FranP-code/Baileys.git
synced 2025-10-13 00:32:22 +00:00
feat: Add max msg retry count (#572)
This commit is contained in:
@@ -134,6 +134,8 @@ type SocketConfig = {
|
|||||||
customUploadHosts: MediaConnInfo['hosts']
|
customUploadHosts: MediaConnInfo['hosts']
|
||||||
/** time to wait between sending new retry requests */
|
/** time to wait between sending new retry requests */
|
||||||
retryRequestDelayMs: number
|
retryRequestDelayMs: number
|
||||||
|
/** max msg retry count */
|
||||||
|
maxMsgRetryCount: number
|
||||||
/** time to wait for the generation of the next QR in ms */
|
/** time to wait for the generation of the next QR in ms */
|
||||||
qrTimeout?: number;
|
qrTimeout?: number;
|
||||||
/** provide an auth state object to maintain the auth state */
|
/** provide an auth state object to maintain the auth state */
|
||||||
|
|||||||
@@ -65,6 +65,7 @@ export const DEFAULT_CONNECTION_CONFIG: SocketConfig = {
|
|||||||
defaultQueryTimeoutMs: 60_000,
|
defaultQueryTimeoutMs: 60_000,
|
||||||
customUploadHosts: [],
|
customUploadHosts: [],
|
||||||
retryRequestDelayMs: 250,
|
retryRequestDelayMs: 250,
|
||||||
|
maxMsgRetryCount: 5,
|
||||||
fireInitQueries: true,
|
fireInitQueries: true,
|
||||||
auth: undefined as unknown as AuthenticationState,
|
auth: undefined as unknown as AuthenticationState,
|
||||||
markOnlineOnConnect: true,
|
markOnlineOnConnect: true,
|
||||||
|
|||||||
@@ -45,6 +45,7 @@ export const makeMessagesRecvSocket = (config: SocketConfig) => {
|
|||||||
const {
|
const {
|
||||||
logger,
|
logger,
|
||||||
retryRequestDelayMs,
|
retryRequestDelayMs,
|
||||||
|
maxMsgRetryCount,
|
||||||
getMessage,
|
getMessage,
|
||||||
shouldIgnoreJid
|
shouldIgnoreJid
|
||||||
} = config
|
} = config
|
||||||
@@ -130,7 +131,7 @@ export const makeMessagesRecvSocket = (config: SocketConfig) => {
|
|||||||
const msgId = node.attrs.id
|
const msgId = node.attrs.id
|
||||||
|
|
||||||
let retryCount = msgRetryCache.get<number>(msgId) || 0
|
let retryCount = msgRetryCache.get<number>(msgId) || 0
|
||||||
if(retryCount >= 5) {
|
if(retryCount >= maxMsgRetryCount) {
|
||||||
logger.debug({ retryCount, msgId }, 'reached retry limit, clearing')
|
logger.debug({ retryCount, msgId }, 'reached retry limit, clearing')
|
||||||
msgRetryCache.del(msgId)
|
msgRetryCache.del(msgId)
|
||||||
return
|
return
|
||||||
@@ -503,7 +504,7 @@ export const makeMessagesRecvSocket = (config: SocketConfig) => {
|
|||||||
const willSendMessageAgain = (id: string, participant: string) => {
|
const willSendMessageAgain = (id: string, participant: string) => {
|
||||||
const key = `${id}:${participant}`
|
const key = `${id}:${participant}`
|
||||||
const retryCount = msgRetryCache.get<number>(key) || 0
|
const retryCount = msgRetryCache.get<number>(key) || 0
|
||||||
return retryCount < 5
|
return retryCount < maxMsgRetryCount
|
||||||
}
|
}
|
||||||
|
|
||||||
const updateSendMessageAgainCount = (id: string, participant: string) => {
|
const updateSendMessageAgainCount = (id: string, participant: string) => {
|
||||||
|
|||||||
@@ -51,6 +51,8 @@ export type SocketConfig = {
|
|||||||
customUploadHosts: MediaConnInfo['hosts']
|
customUploadHosts: MediaConnInfo['hosts']
|
||||||
/** time to wait between sending new retry requests */
|
/** time to wait between sending new retry requests */
|
||||||
retryRequestDelayMs: number
|
retryRequestDelayMs: number
|
||||||
|
/** max retry count */
|
||||||
|
maxMsgRetryCount: number
|
||||||
/** time to wait for the generation of the next QR in ms */
|
/** time to wait for the generation of the next QR in ms */
|
||||||
qrTimeout?: number
|
qrTimeout?: number
|
||||||
/** provide an auth state object to maintain the auth state */
|
/** provide an auth state object to maintain the auth state */
|
||||||
|
|||||||
Reference in New Issue
Block a user