logger

Self-hosted WhatsApp logger us...
Log | Files | Refs | Activity

commit 579be0da58257d93510acd93848fcae9f0555761
parent 7c07ebbbadecadfe27a1940876116fa336323921
Author: Amit Dutta <mail@amit.is-a.dev>
Date:   Sat, 29 Aug 2026 07:08:17 +0530

Merge pull request #4 from notamitgamer/feature/full-resync-endpoint

Full resync endpoint for Reset flow (with real progress)
Diffstat:
Msrc/config.js | 2+-
Msrc/routes/api.js | 41+++++++++++++++++++++++++++++++++++++++++
2 files changed, 42 insertions(+), 1 deletion(-)

diff --git a/src/config.js b/src/config.js @@ -4,7 +4,7 @@ const AUTH_USER = process.env.AUTH_USER; const AUTH_PASS = process.env.AUTH_PASS; const MAX_LOGS = 500; const MAX_CONNECTIONS_PER_TOKEN = 15; -const VERSION = '4.2.2'; +const VERSION = '4.2.3'; const EXCLUDED_JIDS = new Set(['917278779512@s.whatsapp.net', '201554426618024@lid']); module.exports = { diff --git a/src/routes/api.js b/src/routes/api.js @@ -150,6 +150,47 @@ router.get('/api/sync/stream', verifyApiToken, async (req, res) => { } }); +// --- API: Full Resync (used by the client's "Reset" flow) --- +// Lightweight manifest: chat metadata + per-chat message counts, no message +// bodies. Lets the client know the true total up front so it can show real +// download progress instead of a fake/local-only percentage. +router.get('/api/export/chats', verifyApiToken, async (req, res) => { + if (!isCacheReady()) return res.status(503).json({ error: 'Cache still warming, retry shortly' }); + + try { + const chats = []; + let totalMessages = 0; + + chatsCache.forEach((data, id) => { + const count = messagesCache.has(id) ? messagesCache.get(id).size : 0; + totalMessages += count; + chats.push({ ...data, messageCount: count }); + }); + + res.json({ chats, totalMessages }); + } catch (err) { + res.status(500).json({ error: err.message }); + } +}); + +// Plain JSON (not SSE) — all messages for a single chat. Called once per +// chat by the client's resync loop so progress can be updated after each +// chat finishes, instead of waiting on one all-chats blob. +router.get('/api/export/messages', verifyApiToken, async (req, res) => { + if (!isCacheReady()) return res.status(503).json({ error: 'Cache still warming, retry shortly' }); + + const { chatId } = req.query; + if (!chatId) return res.status(400).json({ error: 'Missing chatId' }); + + try { + const msgMap = messagesCache.get(chatId); + const messages = msgMap ? Array.from(msgMap.values()) : []; + res.json({ chatId, messages }); + } catch (err) { + res.status(500).json({ error: err.message }); + } +}); + // --- API: Standard Actions --- router.post('/api/rename', verifyApiToken, async (req, res) => { if (!isCacheReady()) return res.status(503).json({ error: 'Cache still warming, retry shortly' });
© notamitgamer • Site Built: 2026-09-05 01:53:16 UTC • git-mirror commit: c170d72 [view raw info]
Originally created with stagit • modified by notamitgamer
Forked from github.com/notamitgamer/git-mirror