From c7cabae86753de4b81ac00b4162d3e457bdca91c Mon Sep 17 00:00:00 2001 From: nexy7574 Date: Mon, 28 Apr 2025 01:38:55 +0000 Subject: [PATCH] fix: Do not panic when sender_device is None in `/messages` route The device ID is not always present when the appservice is the client. This was causing 500 errors for some users, as appservices can lazy load from `/messages`. Co-authored-by: Jade Ellis Co-authored-by: Jason Volk Signed-off-by: Jason Volk --- src/api/client/message.rs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/api/client/message.rs b/src/api/client/message.rs index 88451b0d..5d46e394 100644 --- a/src/api/client/message.rs +++ b/src/api/client/message.rs @@ -67,8 +67,8 @@ pub(crate) async fn get_message_events_route( body: Ruma, ) -> Result { debug_assert!(IGNORED_MESSAGE_TYPES.is_sorted(), "IGNORED_MESSAGE_TYPES is not sorted"); - let sender = body.sender(); - let (sender_user, sender_device) = sender; + let sender_user = body.sender_user(); + let sender_device = body.sender_device.as_deref(); let room_id = &body.room_id; let filter = &body.filter; @@ -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: Some(sender_device), + device_id: sender_device, room_id, token: Some(from.into_unsigned()), options: Some(&filter.lazy_load_options),