@@ -16,7 +16,11 @@ use std::{collections::BTreeMap, time::Duration};
1616
1717use futures_util:: future:: join_all;
1818use matrix_sdk_common:: failures_cache:: FailuresCache ;
19- use ruma:: OwnedRoomId ;
19+ use ruma:: {
20+ events:: room:: encrypted:: { EncryptedEventScheme , OriginalSyncRoomEncryptedEvent } ,
21+ serde:: Raw ,
22+ OwnedRoomId ,
23+ } ;
2024use tokio:: sync:: mpsc:: { self , UnboundedReceiver } ;
2125use tracing:: { trace, warn} ;
2226
@@ -124,8 +128,21 @@ impl BackupDownloadTask {
124128 Self { sender, join_handle }
125129 }
126130
127- pub ( crate ) fn trigger_download ( & self , room_key_info : RoomKeyInfo ) {
128- let _ = self . sender . send ( room_key_info) ;
131+ /// Trigger a backup download for the keys for the given event.
132+ ///
133+ /// Does nothing unless the event is encrypted using `m.megolm.v1.aes-sha2`.
134+ /// Otherwise, tells the listener task to set off a task to do a backup
135+ /// download, unless there is one already running.
136+ pub ( crate ) fn trigger_download_for_utd_event (
137+ & self ,
138+ room_id : OwnedRoomId ,
139+ event : Raw < OriginalSyncRoomEncryptedEvent > ,
140+ ) {
141+ if let Ok ( deserialized_event) = event. deserialize ( ) {
142+ if let EncryptedEventScheme :: MegolmV1AesSha2 ( c) = deserialized_event. content . scheme {
143+ let _ = self . sender . send ( ( room_id, c. session_id ) ) ;
144+ }
145+ }
129146 }
130147
131148 pub ( crate ) async fn download (
0 commit comments