@@ -74,9 +74,13 @@ use crate::{
7474
7575mod deduplicator;
7676mod pagination;
77+ #[ cfg( feature = "e2e-encryption" ) ]
78+ mod redecryptor;
7779mod room;
7880
7981pub use pagination:: { RoomPagination , RoomPaginationStatus } ;
82+ #[ cfg( feature = "e2e-encryption" ) ]
83+ pub use redecryptor:: { DecryptionRetryRequest , RedecryptorReport } ;
8084pub use room:: { RoomEventCache , RoomEventCacheSubscriber , ThreadEventCacheUpdate } ;
8185
8286/// An error observed in the [`EventCache`].
@@ -148,6 +152,10 @@ pub struct EventCacheDropHandles {
148152
149153 /// The task used to automatically shrink the linked chunks.
150154 auto_shrink_linked_chunk_task : JoinHandle < ( ) > ,
155+
156+ /// The task used to automatically redecrypt UTDs.
157+ #[ cfg( feature = "e2e-encryption" ) ]
158+ _redecryptor : redecryptor:: Redecryptor ,
151159}
152160
153161impl fmt:: Debug for EventCacheDropHandles {
@@ -200,6 +208,9 @@ impl EventCache {
200208 linked_chunk_update_sender. clone ( ) ,
201209 ) ) ) ;
202210
211+ #[ cfg( feature = "e2e-encryption" ) ]
212+ let redecryption_channels = redecryptor:: RedecryptorChannels :: new ( ) ;
213+
203214 Self {
204215 inner : Arc :: new ( EventCacheInner {
205216 client,
@@ -213,6 +224,8 @@ impl EventCache {
213224 _thread_subscriber_task : thread_subscriber_task,
214225 #[ cfg( feature = "experimental-search" ) ]
215226 _search_indexing_task : search_indexing_task,
227+ #[ cfg( feature = "e2e-encryption" ) ]
228+ redecryption_channels,
216229 thread_subscriber_receiver,
217230 } ) ,
218231 }
@@ -257,10 +270,26 @@ impl EventCache {
257270 auto_shrink_receiver,
258271 ) ) ;
259272
273+ #[ cfg( feature = "e2e-encryption" ) ]
274+ let redecryptor = {
275+ let receiver = self
276+ . inner
277+ . redecryption_channels
278+ . decryption_request_receiver
279+ . lock ( )
280+ . take ( )
281+ . expect ( "We should have initialized the channel an subscribing should happen only once" ) ;
282+
283+ redecryptor:: Redecryptor :: new ( Arc :: downgrade ( & self . inner ) , receiver)
284+ } ;
285+
286+
260287 Arc :: new ( EventCacheDropHandles {
261288 listen_updates_task,
262289 ignore_user_list_update_task,
263290 auto_shrink_linked_chunk_task,
291+ #[ cfg( feature = "e2e-encryption" ) ]
292+ _redecryptor : redecryptor,
264293 } )
265294 } ) ;
266295
@@ -840,6 +869,9 @@ struct EventCacheInner {
840869 /// This is helpful for tests to coordinate that a new thread subscription
841870 /// has been sent or not.
842871 thread_subscriber_receiver : Receiver < ( ) > ,
872+
873+ #[ cfg( feature = "e2e-encryption" ) ]
874+ redecryption_channels : redecryptor:: RedecryptorChannels ,
843875}
844876
845877type AutoShrinkChannelPayload = OwnedRoomId ;
0 commit comments