@@ -34,7 +34,10 @@ use crate::{
3434 SenderData ,
3535 } ,
3636 types:: {
37- events:: { room_key_bundle:: RoomKeyBundleContent , room_key_withheld:: RoomKeyWithheldEvent } ,
37+ events:: {
38+ room_key_bundle:: RoomKeyBundleContent ,
39+ room_key_withheld:: { RoomKeyWithheldContent , RoomKeyWithheldEvent } ,
40+ } ,
3841 EventEncryptionAlgorithm ,
3942 } ,
4043 Account , Device , DeviceData , GossippedSecret , Session , UserIdentity , UserIdentityData ,
@@ -75,7 +78,7 @@ pub struct Changes {
7578 pub identities : IdentityChanges ,
7679 pub devices : DeviceChanges ,
7780 /// Stores when a `m.room_key.withheld` is received
78- pub withheld_session_info : BTreeMap < OwnedRoomId , BTreeMap < String , RoomKeyWithheldEvent > > ,
81+ pub withheld_session_info : BTreeMap < OwnedRoomId , BTreeMap < String , RoomKeyWithheldEntry > > ,
7982 pub room_settings : HashMap < OwnedRoomId , RoomSettings > ,
8083 pub secrets : Vec < GossippedSecret > ,
8184 pub next_batch_token : Option < String > ,
@@ -484,9 +487,31 @@ pub struct RoomKeyWithheldInfo {
484487 /// The ID of the session that the key is for.
485488 pub session_id : String ,
486489
487- /// The `m.room_key.withheld` event that notified us that the key is being
488- /// withheld.
489- pub withheld_event : RoomKeyWithheldEvent ,
490+ /// The withheld entry from a `m.room_key.withheld` event or [MSC4268] room
491+ /// key bundle.
492+ ///
493+ /// [MSC4268]: https://github.com/matrix-org/matrix-spec-proposals/pull/4268
494+ pub withheld_event : RoomKeyWithheldEntry ,
495+ }
496+
497+ /// Represents an entry for a withheld room key event, which can be either a
498+ /// to-device event or a bundle entry.
499+ #[ derive( Clone , Debug , Serialize , Deserialize ) ]
500+ pub struct RoomKeyWithheldEntry {
501+ /// The user ID responsible for this entry, either from a
502+ /// `m.room_key.withheld` to-device event or an [MSC4268] room key bundle.
503+ ///
504+ /// [MSC4268]: https://github.com/matrix-org/matrix-spec-proposals/pull/4268
505+ pub sender : OwnedUserId ,
506+ /// The content of the entry, which provides details about the reason the
507+ /// key was withheld.
508+ pub content : RoomKeyWithheldContent ,
509+ }
510+
511+ impl From < RoomKeyWithheldEvent > for RoomKeyWithheldEntry {
512+ fn from ( value : RoomKeyWithheldEvent ) -> Self {
513+ Self { sender : value. sender , content : value. content }
514+ }
490515}
491516
492517/// Information about a received historic room key bundle.
0 commit comments