Repository navigation
fix(chat-store): materialize deliberately shared group history - #246
Conversation
|
Note Currently processing new changes in this PR. This may take a few minutes, please wait... ⚙️ Run configuration
📒 Files selected for processing: 23
✨ Finishing Touches
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 3ba44468db
ℹ️ 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".
| &message, | ||
| cs, | ||
| &mut quotes, | ||
| true, |
There was a problem hiding this comment.
Keep shared edit and revoke placeholders out of unread counts
When a bundle contains an edit or revoke whose target is not already stored, apply_history_message calls apply_edit or apply_revoke, which inserts a placeholder and increments the chat's unread count for incoming authors. The new shared flag only marks rows in the MessageOp::Store branch, so these placeholders also retain received_as_shared_history = false and remain eligible for later unread recounts. Consequently, importing old shared history can create unread badges and unread timeline entries despite the final zero-delta chat bump. Propagate the shared-history origin into these insertion paths and suppress their unread contribution.
Useful? React with 👍 / 👎.
| let author = stored_sender(author, false); | ||
| key.from_me = Some(own.contains(&author)); | ||
| key.participant = Some(author.clone()); | ||
| message.participant = Some(author); |
There was a problem hiding this comment.
Translate or remove aggregated reaction keys before importing
For a shared primary message carrying WebMessageInfo.reactions, only the outer message key and protocol target key are translated; the aggregated reaction keys retain the sharing account's perspective. apply_history_message nevertheless imports every aggregated reaction and interprets a reaction key with from_me = true as the local account's empty sender sentinel. This stores the sharing account's reactions under the wrong identity and prevents subsequent reactions or removals from that account from replacing them. Translate these nested keys before forwarding the message, or clear the reactions if add-on import is intentionally unsupported.
Useful? React with 👍 / 👎.
| let changed = diesel::sql_query("UPDATE shared_group_history SET completed = TRUE, proto = X'' WHERE device_id = ? AND chat_jid = ? AND msg_id = ? AND sender_jid = ? AND proto = ? AND timestamp_ms = ? AND completed = FALSE") | ||
| .bind::<Integer,_>(device).bind::<Text,_>(&bundle.chat_jid).bind::<Text,_>(&bundle.msg_id).bind::<Text,_>(&bundle.sender_jid).bind::<Binary,_>(&bundle.proto).bind::<BigInt,_>(bundle.timestamp_ms).execute(conn)?; | ||
| if changed == 0 { | ||
| return Ok(()); |
There was a problem hiding this comment.
Retire pending history when its chat is cleared or deleted
If a clear/delete-chat update is applied after a bundle is persisted but before its download completes, the attachment remains pending: DeleteChatUpdate and ClearChatUpdate call delete_chat_rows, which removes messages and their reactions/receipts but never retires shared_group_history entries. Repository-wide searches for the new table and discard API confirm there is no deletion integration elsewhere. This completion check therefore still accepts the attachment, imports the old messages, and even recreates a deleted chat through bump_chat. Retire pending attachments covered by the clear/delete action in the same transaction, retaining their deduplication records so redelivery cannot restore the cleared history.
Useful? React with 👍 / 👎.
Received pairwise
messageHistoryBundleattachments became unknown timeline rows, and their shared messages were never imported.Persist eligible attachments inside the inbound durability transaction and consume them through a serial, bounded session downloader. Apply supported primary history messages with stale-copy semantics, translate sender keys from the sharing account's perspective, retain idempotency across restart, and keep imported history out of unread recounts. Classify visible notices as system lines, repair legacy carrier rows, and recover a revoke placeholder's original position without restoring deleted content.
Protocol evidence, bundle hashes, module offsets and limitations are recorded in the investigation. All 579 bundles from whatspec
46f6304, schema 4.4.0 / Web 2.3000.1047483476, were verified against the same commit's lock. Current engine and bridge source do not provide receiver materialization.Validation:
0ba4118and passes here.No authenticated reproduction was performed. This imports supported primary
GroupHistory.messages; reporting-token, add-on and out-of-window-pin parity remain outside this correction. Only explicitly shared attachments are downloaded.Hosted CI on
3ba4446passed: CI ran 2,063 native tests with 13 skips; release artifacts built all four platforms and verified the downloaded archives; Pages built successfully with Publish skipped for this draft. Native Nextest reported one leaky existing daemon launcher fixture, which passed and is untouched here.Closes #245.
Summary by cubic
Received
messageHistoryBundleattachments now materialize shared group history instead of surfacing as unknown timeline rows whose messages were never imported.Closes #245.
Written for commit 3ba4446. Summary will update on new commits.
Summary by CodeRabbit