Skip to content

fix whatsapp disappearing messages timer not applied to sent messages - #597

Open
emersonjb wants to merge 2 commits into
d99kris:masterfrom
emersonjb:fix-whatsapp-disappearing-timer
Open

emersonjb wants to merge 2 commits into
d99kris:masterfrom
emersonjb:fix-whatsapp-disappearing-timer

Conversation

@emersonjb

Copy link
Copy Markdown

Type of change

Description

Problem: messages sent from nchat to a WhatsApp chat with disappearing messages enabled carried no timer, so they did not disappear and the phone showed a timer conflict. The per-chat expiration used when sending (GetExpiration) was only ever set for groups, once at startup, and never for 1:1 chats.

Fix (lib/wmchat/go/gowm.go only, +81/-8): record the timer from every source whatsmeow provides, and keep it across restarts.

  • HandleHistorySync: read Conversation.EphemeralExpiration.
  • HandleProtocolMessage: handle EPHEMERAL_SETTING (timer changed in a 1:1 chat, by either side).
  • HandleGroupInfo: handle GroupInfo.Ephemeral (timer changed in a group).
  • GetContacts: set the group timer unconditionally, so a timer turned off while nchat was closed is cleared.
  • HandleMessage: after the message has been handled, read ContextInfo.Expiration from it. This is the only source for a chat started by a peer with a default timer, since no EPHEMERAL_SETTING is sent then. It also bootstraps existing profiles without a new history sync.
  • SetExpiration saves the map to expirations.dat in the profile dir (gob, like contacts.dat / senders.dat) when a value changes, and AddConn loads it.

Upgrading from a previous version needs no migration: a missing expirations.dat means no timers known, which is today's behaviour. Groups get their timers from GetContacts on the first run, and 1:1 chats as soon as a message arrives in them.

Testing

  • ./make.sh build on Arch Linux x86_64 (based on c1c3e5a), and go build of lib/wmchat/go on current master; gofmt and go vet report nothing new.
  • Unit-tested the new helpers in a scratch test (not included): reading the timer from text, image, reaction and no-context messages, explicit zero, load/save round trip, missing file, unchanged values, and closed connections.
  • With a real account, on a build of the final commit: sent a message from nchat to a 1:1 chat with a 90-day timer. It was received with the correct timer and no conflict.

AI tools (Claude) were used to write this change; I've built, tested and reviewed it.

🤖 Generated with Claude Code

emersonjb and others added 2 commits September 19, 2026 11:50
The per-chat expiration attached to outgoing messages was only recorded
for groups, and only once at startup. Messages sent to 1:1 chats with
disappearing messages enabled therefore carried no timer: they did not
disappear, and the official clients flagged a timer conflict.

Record the timer from every source whatsmeow provides: the conversation
setting in history sync, EPHEMERAL_SETTING protocol messages, group info
changes, the joined-groups list (now also clearing timers that were
turned off), and the context info of incoming messages, which is the only
source for chats started by a peer with a default timer. Timers are saved
to expirations.dat in the profile dir on change, so they survive restarts.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Read the timer from an incoming message only once the message itself has
been handled, so a failure in that step can never cause the message to be
lost.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
@d99kris d99kris self-assigned this Sep 20, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants