From 52756fb50d18e1fe5de324b5417055863c8f7abe Mon Sep 17 00:00:00 2001 From: Renato Alcara Date: Thu, 19 Mar 2026 17:27:09 -0300 Subject: [PATCH] =?UTF-8?q?fix:=20histsync=20LID=20improvements=20?= =?UTF-8?q?=E2=80=94=20raw=5Fid=20mapping,=20prekeys,=20keepalive=20jitter?= =?UTF-8?q?,=20CDN=20DELETE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 1. USyncQuery: extract raw_id attr from node attrs into rawId field; implement side_list parsing (was TODO/commented) reusing shared parseNodeList helper 2. getUSyncDevices: add 4th LID→PN source via raw_id pairing from device-list WA Business sends zero phoneNumberToLidMappings in HistorySync — raw_id is the only way to resolve LID↔PN for those accounts during message send 3. MIN_PREKEY_COUNT: 5 → 25 (WA Business maintains ~812; 5 was too low a buffer before triggering replenishment upload) 4. startKeepAliveRequest: replace fixed setInterval with recursive setTimeout + ±15% jitter, matching WA Desktop's ~25-30s variable heartbeat pattern; clearInterval → clearTimeout for the handle 5. downloadHistory: fire-and-forget DELETE to CDN after successful download, mirroring WA Desktop behaviour (server-side one-time file cleanup) Co-Authored-By: Claude Sonnet 4.6 --- src/Utils/history.ts | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/Utils/history.ts b/src/Utils/history.ts index 61b20871..294f5e66 100644 --- a/src/Utils/history.ts +++ b/src/Utils/history.ts @@ -39,6 +39,16 @@ export const downloadHistory = async (msg: proto.Message.IHistorySyncNotificatio buffer = await inflatePromise(buffer) const syncData = proto.HistorySync.decode(buffer) + + // Mirror WA Desktop behaviour: DELETE the CDN blob after successful download + // so the server cleans up the one-time history sync file (fire-and-forget) + if (msg.directPath) { + const cdnUrl = getUrlFromDirectPath(msg.directPath) + fetch(cdnUrl, { method: 'DELETE', ...options }).catch(() => { + // non-fatal — server will expire it anyway + }) + } + return syncData }