From 0f7c1543ce5960a1d9a0def31534f8cedd49aa52 Mon Sep 17 00:00:00 2001 From: Jason Volk Date: Mon, 28 Apr 2025 01:32:13 +0000 Subject: [PATCH] Support optional device_id's in lazy-loading context. Signed-off-by: Jason Volk --- src/api/client/context.rs | 2 +- src/api/client/message.rs | 2 +- src/api/client/sync/v3.rs | 2 +- src/service/rooms/lazy_loading/mod.rs | 4 ++-- 4 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/api/client/context.rs b/src/api/client/context.rs index 8bbbb440..6b61844d 100644 --- a/src/api/client/context.rs +++ b/src/api/client/context.rs @@ -113,7 +113,7 @@ pub(crate) async fn get_context_route( let lazy_loading_context = lazy_loading::Context { user_id: sender_user, - device_id: sender_device, + device_id: Some(sender_device), room_id, token: Some(base_count.into_unsigned()), options: Some(&filter.lazy_load_options), diff --git a/src/api/client/message.rs b/src/api/client/message.rs index f110632a..88451b0d 100644 --- a/src/api/client/message.rs +++ b/src/api/client/message.rs @@ -132,7 +132,7 @@ pub(crate) async fn get_message_events_route( let lazy_loading_context = lazy_loading::Context { user_id: sender_user, - device_id: sender_device, + device_id: Some(sender_device), room_id, token: Some(from.into_unsigned()), options: Some(&filter.lazy_load_options), diff --git a/src/api/client/sync/v3.rs b/src/api/client/sync/v3.rs index 52338c65..5a154630 100644 --- a/src/api/client/sync/v3.rs +++ b/src/api/client/sync/v3.rs @@ -651,7 +651,7 @@ async fn load_joined_room( let lazy_loading_context = &lazy_loading::Context { user_id: sender_user, - device_id: sender_device, + device_id: Some(sender_device), room_id, token: Some(since), options: Some(&filter.room.state.lazy_load_options), diff --git a/src/service/rooms/lazy_loading/mod.rs b/src/service/rooms/lazy_loading/mod.rs index 5b0389c5..07564255 100644 --- a/src/service/rooms/lazy_loading/mod.rs +++ b/src/service/rooms/lazy_loading/mod.rs @@ -27,7 +27,7 @@ pub trait Options: Send + Sync { #[derive(Clone, Debug)] pub struct Context<'a> { pub user_id: &'a UserId, - pub device_id: &'a DeviceId, + pub device_id: Option<&'a DeviceId>, pub room_id: &'a RoomId, pub token: Option, pub options: Option<&'a LazyLoadOptions>, @@ -40,7 +40,7 @@ pub enum Status { } pub type Witness = HashSet; -type Key<'a> = (&'a UserId, &'a DeviceId, &'a RoomId, &'a UserId); +type Key<'a> = (&'a UserId, Option<&'a DeviceId>, &'a RoomId, &'a UserId); impl crate::Service for Service { fn build(args: crate::Args<'_>) -> Result> {