matrix-org / matrix-rust-sdk

Matrix Client-Server SDK for Rust
Apache License 2.0
1.19k stars 235 forks source link

timeline: `is_room_encrypted` should be part of the `RoomProvider` trait #3850

Open bnjbvr opened 3 weeks ago

bnjbvr commented 3 weeks ago

Otherwise, the timeline won't correctly handle a transition from an unencrypted room to an encrypted one, which will be visible in embedders as shields not appearing in this case. Not only there's a correctness issue, but also for consistency with the rest of the RoomProvider trait's methods, which all return dynamic data about the Room.

cc @pixlwave

pixlwave commented 3 weeks ago

My bad, I didn't consider that a room could be upgraded to use encryption 🙈

jmartinesp commented 4 days ago

After discussing this we agreed a potential fix for this could be:

  1. Have a RwLock<Option<bool>> is_encrypted in the state, that's touched by the different sources, populated by either the previous events or room.is_encrypted().await.ok(), then updated via state events from sync.
  2. When creating timeline items, use it to get the encryption state that's passed to the timeline items.
  3. If no encryption state is found, assume it's unencrypted there and not display any shields.