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`. Fixes #738 Co-authored-by: Jade Ellis <jade@ellis.link>
This commit is contained in:
parent
773c3d457b
commit
68d68a0645
1 changed files with 4 additions and 4 deletions
|
@ -21,7 +21,7 @@ use conduwuit_service::{
|
||||||
};
|
};
|
||||||
use futures::{FutureExt, StreamExt, TryFutureExt, future::OptionFuture, pin_mut};
|
use futures::{FutureExt, StreamExt, TryFutureExt, future::OptionFuture, pin_mut};
|
||||||
use ruma::{
|
use ruma::{
|
||||||
RoomId, UserId,
|
DeviceId, RoomId, UserId,
|
||||||
api::{
|
api::{
|
||||||
Direction,
|
Direction,
|
||||||
client::{filter::RoomEventFilter, message::get_message_events},
|
client::{filter::RoomEventFilter, message::get_message_events},
|
||||||
|
@ -67,8 +67,8 @@ pub(crate) async fn get_message_events_route(
|
||||||
body: Ruma<get_message_events::v3::Request>,
|
body: Ruma<get_message_events::v3::Request>,
|
||||||
) -> Result<get_message_events::v3::Response> {
|
) -> Result<get_message_events::v3::Response> {
|
||||||
debug_assert!(IGNORED_MESSAGE_TYPES.is_sorted(), "IGNORED_MESSAGE_TYPES is not sorted");
|
debug_assert!(IGNORED_MESSAGE_TYPES.is_sorted(), "IGNORED_MESSAGE_TYPES is not sorted");
|
||||||
let sender = body.sender();
|
let sender_user = body.sender_user();
|
||||||
let (sender_user, sender_device) = sender;
|
let sender_device = body.sender_device.as_ref();
|
||||||
let room_id = &body.room_id;
|
let room_id = &body.room_id;
|
||||||
let filter = &body.filter;
|
let filter = &body.filter;
|
||||||
|
|
||||||
|
@ -132,7 +132,7 @@ pub(crate) async fn get_message_events_route(
|
||||||
|
|
||||||
let lazy_loading_context = lazy_loading::Context {
|
let lazy_loading_context = lazy_loading::Context {
|
||||||
user_id: sender_user,
|
user_id: sender_user,
|
||||||
device_id: sender_device,
|
device_id: sender_device.map_or_else(|| <&DeviceId>::from(""), AsRef::as_ref),
|
||||||
room_id,
|
room_id,
|
||||||
token: Some(from.into_unsigned()),
|
token: Some(from.into_unsigned()),
|
||||||
options: Some(&filter.lazy_load_options),
|
options: Some(&filter.lazy_load_options),
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue