Conversation
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>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Type of change
pr-welcomein discussion #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.goonly, +81/-8): record the timer from every source whatsmeow provides, and keep it across restarts.HandleHistorySync: readConversation.EphemeralExpiration.HandleProtocolMessage: handleEPHEMERAL_SETTING(timer changed in a 1:1 chat, by either side).HandleGroupInfo: handleGroupInfo.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, readContextInfo.Expirationfrom it. This is the only source for a chat started by a peer with a default timer, since noEPHEMERAL_SETTINGis sent then. It also bootstraps existing profiles without a new history sync.SetExpirationsaves the map toexpirations.datin the profile dir (gob, likecontacts.dat/senders.dat) when a value changes, andAddConnloads it.Upgrading from a previous version needs no migration: a missing
expirations.datmeans no timers known, which is today's behaviour. Groups get their timers fromGetContactson the first run, and 1:1 chats as soon as a message arrives in them.Testing
./make.sh buildon Arch Linux x86_64 (based on c1c3e5a), andgo buildoflib/wmchat/goon current master;gofmtandgo vetreport nothing new.AI tools (Claude) were used to write this change; I've built, tested and reviewed it.
🤖 Generated with Claude Code