diff --git a/src/api/client_server/presence.rs b/src/api/client_server/presence.rs index 583b8798..9bcd7ba9 100644 --- a/src/api/client_server/presence.rs +++ b/src/api/client_server/presence.rs @@ -79,11 +79,6 @@ pub async fn get_presence_route( presence: presence.content.presence, }) } else { - Ok(get_presence::v3::Response { - status_msg: None, - currently_active: None, - last_active_ago: None, - presence: PresenceState::Offline, - }) + Ok(get_presence::v3::Response::new(PresenceState::Offline)) } } diff --git a/src/database/key_value/rooms/edus/presence.rs b/src/database/key_value/rooms/edus/presence.rs index ee41584a..b5e10e10 100644 --- a/src/database/key_value/rooms/edus/presence.rs +++ b/src/database/key_value/rooms/edus/presence.rs @@ -185,31 +185,20 @@ impl service::rooms::edus::presence::Data for KeyValueDatabase { Ok(Box::new( self.roomuserid_presenceevent .scan_prefix(room_id.as_bytes().to_vec()) - .filter_map(|(roomuserid_bytes, presence_bytes)| { - let user_id_bytes = - roomuserid_bytes.split(|byte| *byte == 0xff as u8).last()?; - Some(( - UserId::parse( - utils::string_from_bytes(&user_id_bytes) - .expect("UserID bytes are a valid string"), - ) - .expect("UserID bytes from database are a valid UserID") - .to_owned(), - presence_bytes, - )) - }) - .filter_map( - move |(user_id, presence_bytes)| -> Option<(OwnedUserId, PresenceEvent)> { - let timestamp = user_timestamp.get(&user_id)?; + .filter_map(move |(roomuserid_bytes, presence_bytes)| { + let user_id_bytes = roomuserid_bytes.split(|byte| *byte == 0xff).last()?; + let user_id: OwnedUserId = UserId::parse( + utils::string_from_bytes(&user_id_bytes) + .expect("UserID bytes are a valid string"), + ) + .expect("UserID bytes from database are a valid UserID"); - Some(( - user_id, - parse_presence_event(&presence_bytes, *timestamp).expect( - "PresenceEvent bytes from database are a valid PresenceEvent", - ), - )) - }, - ), + let timestamp = user_timestamp.get(&user_id)?; + let presence_event = parse_presence_event(&presence_bytes, *timestamp) + .expect("PresenceEvent bytes from database are a valid PresenceEvent"); + + Some((user_id, presence_event)) + }), )) }