fix(bridge): preserve original timestamp on retry-redelivered messages - #149
Open
malyszm wants to merge 2 commits into
Open
fix(bridge): preserve original timestamp on retry-redelivered messages#149malyszm wants to merge 2 commits into
malyszm wants to merge 2 commits into
Conversation
malyszm
force-pushed
the
fix/retry-redelivery-timestamp
branch
from
July 1, 2026 14:23
2717226 to
34f1059
Compare
When the bridge has been offline for a while (an outage, or the periodic linked-device session expiry), incoming messages can fail to decrypt on first delivery because the local Signal session lacks the current sender key. whatsmeow sends a retry receipt and WhatsApp re-sends the message, but the re-sent stanza's `t` attribute is the resend time, not the original send time. The bridge stored that resend time, so messages actually sent hours or days earlier were stamped at reconnect time — corrupting recency-ordered views (last-message-per-chat, chat sort order) for the affected messages until they aged out. The original timestamp is recoverable: the first (undecryptable) delivery carries it, and whatsmeow surfaces it via events.UndecryptableMessage moments before the retry resend arrives. Cache the original timestamp by message ID when the UndecryptableMessage fires, then reuse it when the decrypted retry lands in handleMessage — guarded to only override when strictly earlier, entries consumed on use, with a soft size cap so a burst of never-retried messages can't grow the map unbounded. Applied to both the content and reaction store paths and to the chat's last-message time. Adds unit tests for the timestamp-cache helpers. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
malyszm
force-pushed
the
fix/retry-redelivery-timestamp
branch
from
July 1, 2026 14:27
34f1059 to
73f2a0c
Compare
Member
|
@codex can you give this a quick look before we merge? |
jack-arturo
previously approved these changes
Jul 16, 2026
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 73f2a0cd6e
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
extractMediaInfo was still fed the raw resend-time msg.Info.Timestamp, so for retry-redelivered media the webhook MediaFilename used the resend time while downloadMedia rebuilds the on-disk name from the stored (original) timestamp — metadata pointed at a filename that never exists. Pass the same retry-corrected msgTimestamp used for storage. Addresses Codex review feedback on verygoodplugins#149. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Author
|
Addressed the Codex feedback in a094d4f — extractMediaInfo now gets the same retry-corrected timestamp that gets stored, so MediaFilename matches the on-disk name downloadMedia rebuilds. @jack-arturo should be good to merge now. |
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.
Summary
tis the resend time, not the original send time, so those messages were stored at reconnect-time — corrupting recency-ordered views (last-message-per-chat and chat sort order) until they aged out.events.UndecryptableMessage(the first delivery carries the truet) and reuse it when the decrypted retry lands inhandleMessage. Guarded to only override when strictly earlier; entries consumed on use with a soft size cap. Applied to the content and reaction store paths and the chat's last-message time.Type of change
fix— bug fixScope check
ROADMAP.md"in scope" list (reliability fix for the Go bridge — reconnect/session-recovery correctness)Linked issues
Testing
golangci-lint runandgo build ./...(Go changes) —go build ./...,go vet ./...,gofmt, andgo test ./...all clean locally (golangci-lint deferred to CI)Using original pre-retry timestamp for <id>…when it fires)Docs
Risk / rollback