logger

Self-hosted WhatsApp logger using Baileys & Firebase. Archives messages instantly to catch deleted texts. Privacy-focused with silent logs.

git clone https://github.com/notamitgamer/logger.git
· rebuilt hourlyOpen on GitHub
commit 9f27ef68f63fac5c0af282a99edddb950c7401fa
parent 7bf46577bf023a1495b772702a892c8f6734713f
Author: notamitgamer-bot <bot@notamitgamer.dev>
Date:   Fri, 11 Sep 2026 08:11:55 +0000

Add diagnostics for edit detection

The fix in #6 handled a race condition, but logs from a real test
(waited well past the retry window) show zero mentions of the edit
at all - not even the failure path. That means the MESSAGE_EDIT
branch itself was never entered, which could mean either:

1. The deployed image is still running pre-#5 code, or
2. WhatsApp/this Baileys version delivers edits with a different
   protocolMessage.type value or shape than assumed

This adds two diagnostics to tell those apart:
- A boot-time build tag log line, so we can confirm from Live Server
  Logs whether this code is actually running
- Logging the raw shape (type + keys) of ANY protocolMessage seen,
  since these are rare in normal traffic and won't be noisy
- A fallback: treat something as an edit if it carries an
  editedMessage payload even if the type enum doesn't match
  MESSAGE_EDIT (14), in case that value differs in practice

Diffstat:
Msrc/whatsapp.js | 20+++++++++++++++++++-
1 file changed, 19 insertions(+), 1 deletion(-)

diff --git a/src/whatsapp.js b/src/whatsapp.js @@ -17,6 +17,12 @@ let consecutiveAuthFailures = 0; let consecutiveConnectFailures = 0; async function startWhatsApp() { + // Temporary build marker for diagnosing the edit-history rollout — + // if this line isn't in the logs after a restart, Render is still + // serving an older image and none of the edit-tracking code below + // is actually running yet. + console.log("System: Build tag = edit-history-diagnostics-v1"); + const logger = pino({ level: 'silent' }); let authResult; @@ -122,7 +128,19 @@ async function startWhatsApp() { // (oldest first) so the UI can show "original -> edit 1 -> edit 2..." // instead of overwriting history. const protocolMsg = msg.message.protocolMessage; - if (protocolMsg && protocolMsg.type === proto.Message.ProtocolMessage.Type.MESSAGE_EDIT) { + + // Diagnostic: log the raw shape of ANY protocol message (edits, + // deletes, app-state syncs, etc.) so we can see exactly what + // WhatsApp is actually sending instead of assuming. protocolMessages + // are rare in normal traffic, so this won't be noisy. + if (protocolMsg) { + console.log(`System: protocolMessage seen in ${remoteJid} — type=${protocolMsg.type}, keys=[${Object.keys(protocolMsg).join(',')}]`); + } + + // Treat it as an edit if either the type enum matches MESSAGE_EDIT, + // OR (as a fallback, in case this Baileys/WA version reports a + // different type value) it simply carries an editedMessage payload. + if (protocolMsg && (protocolMsg.type === proto.Message.ProtocolMessage.Type.MESSAGE_EDIT || protocolMsg.editedMessage)) { const targetId = protocolMsg.key?.id; if (!targetId) { console.error('System: Received MESSAGE_EDIT protocol message with no target key — ignoring.');