fix: Disambiguate appservices in lazy loading context

In the previous commit, app services would all appear to be the same
device when accessing the same user. This sets the device ID to be the
appservice ID when available to avoid possible clobbering.
This commit is contained in:
Jade Ellis 2025-04-16 13:47:35 +01:00 committed by Jacob Taylor
parent 814f321cab
commit b26247e31e

View file

@ -26,7 +26,10 @@ use ruma::{
Direction,
client::{filter::RoomEventFilter, message::get_message_events},
},
events::{AnyStateEvent, StateEventType, TimelineEventType, TimelineEventType::*},
events::{
AnyStateEvent, StateEventType,
TimelineEventType::{self, *},
},
serde::Raw,
};
@ -129,10 +132,20 @@ pub(crate) async fn get_message_events_route(
.take(limit)
.collect()
.await;
// let appservice_id = body.appservice_info.map(|appservice|
// appservice.registration.id);
let lazy_loading_context = lazy_loading::Context {
user_id: sender_user,
device_id: sender_device.map_or_else(|| <&DeviceId>::from(""), AsRef::as_ref),
device_id: match sender_device {
| Some(device_id) => device_id,
| None =>
if let Some(registration) = body.appservice_info.as_ref() {
<&DeviceId>::from(registration.registration.id.as_str())
} else {
<&DeviceId>::from("")
},
},
room_id,
token: Some(from.into_unsigned()),
options: Some(&filter.lazy_load_options),