Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(event cache): redact previously-seen events in the linked chunk too #4536

Merged
merged 4 commits into from
Jan 16, 2025

Conversation

bnjbvr
Copy link
Member

@bnjbvr bnjbvr commented Jan 15, 2025

This makes it possible to:

  • replace one item in a linked chunk, and have all the consumers handle the update. This will be useful for the second part of the PR (applying redactions to the linked chunk), and in the future to replace decrypted events (when decryption happens in the event cache).
  • redact, in memory and in storage, an event by its redacted form, so that it's not possible to read it on disk.

We could add a migration to apply redactions for existing users of the nightly cache. I'd rather do this as a followup, since this PR is growing a bit large already (and another possibility is also to clear all events stored in the event cache, as a dirty yet safe migration — we might need this because I spotted an opportunity to not persist unneeded data from storage).

@bnjbvr bnjbvr requested a review from Hywan January 15, 2025 17:15
@bnjbvr bnjbvr requested a review from a team as a code owner January 15, 2025 17:15
@bnjbvr bnjbvr requested review from a team and andybalaam and removed request for Hywan and a team January 15, 2025 17:20
Copy link

codecov bot commented Jan 15, 2025

Codecov Report

Attention: Patch coverage is 74.77477% with 28 lines in your changes missing coverage. Please review.

Project coverage is 85.39%. Comparing base (c969f90) to head (17db2fb).
Report is 20 commits behind head on main.

Files with missing lines Patch % Lines
...tes/matrix-sdk-ui/src/timeline/controller/state.rs 37.50% 10 Missing ⚠️
crates/matrix-sdk-common/src/linked_chunk/mod.rs 78.94% 4 Missing ⚠️
...s/matrix-sdk-common/src/linked_chunk/relational.rs 50.00% 4 Missing ⚠️
crates/matrix-sdk/src/event_cache/room/events.rs 86.95% 3 Missing ⚠️
crates/matrix-sdk/src/event_cache/room/mod.rs 72.72% 3 Missing ⚠️
crates/matrix-sdk-ui/src/timeline/event_handler.rs 50.00% 2 Missing ⚠️
crates/matrix-sdk-base/src/rooms/normal.rs 50.00% 1 Missing ⚠️
...es/matrix-sdk-common/src/deserialized_responses.rs 80.00% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #4536      +/-   ##
==========================================
- Coverage   85.43%   85.39%   -0.05%     
==========================================
  Files         285      285              
  Lines       32112    32205      +93     
==========================================
+ Hits        27435    27501      +66     
- Misses       4677     4704      +27     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

VectorDiff::Clear => accumulator.clear(),
diff => unimplemented!("{diff:?}"),
}
diff.apply(accumulator);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

Comment on lines +557 to +563
if let Some(updates) = self.updates.as_mut() {
updates.push(Update::ReplaceItem {
at: Position(chunk_identifier, item_index),
item: item.clone(),
});
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Push the update after current_items[item_index] = item;: do the action before triggering the update.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This means we have to clone before, and the original thing is unused if self.updates.as_mut().is_none(). Plus, the updates aren't reflected in real-time, they're buffered until they're consumed, as far as I can tell? So this should be fine to keep as is. I can add a comment explaining that this avoids a clone if you'd like.

Copy link
Member

@andybalaam andybalaam left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good. I'm not hugely confident I understand all the implications, but the code looks good. Some small suggestions and questions, nothing blocking.

@bnjbvr bnjbvr force-pushed the bnjbvr/redact-events-in-storage branch from 4c08194 to c54935d Compare January 16, 2025 11:01
@bnjbvr bnjbvr force-pushed the bnjbvr/redact-events-in-storage branch from c54935d to 17db2fb Compare January 16, 2025 11:04
@bnjbvr bnjbvr enabled auto-merge (rebase) January 16, 2025 11:04
@bnjbvr bnjbvr merged commit 7fa06cb into main Jan 16, 2025
39 checks passed
@bnjbvr bnjbvr deleted the bnjbvr/redact-events-in-storage branch January 16, 2025 11:26
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.

3 participants