refactor for ruma identifiers optimizations

Signed-off-by: Jason Volk <jason@zemos.net>
This commit is contained in:
Jason Volk 2024-12-28 23:31:24 +00:00 committed by strawberry
parent d91570d0e6
commit 0a9b6c136f
19 changed files with 81 additions and 88 deletions

View file

@ -962,7 +962,7 @@ async fn calculate_state_initial(
};
// This check is in case a bad user ID made it into the database
if let Ok(uid) = UserId::parse(&state_key) {
if let Ok(uid) = OwnedUserId::parse(&state_key) {
lazy_loaded.insert(uid);
}
@ -1079,7 +1079,7 @@ async fn calculate_state_incremental(
}
if let Some(state_key) = &state_event.state_key {
let user_id = UserId::parse(state_key.clone())
let user_id = UserId::parse(state_key)
.map_err(|_| Error::bad_database("Invalid UserId in member PDU."))?;
if user_id == sender_user {
@ -1091,15 +1091,15 @@ async fn calculate_state_incremental(
match content.membership {
| MembershipState::Join => {
// A new user joined an encrypted room
if !share_encrypted_room(services, sender_user, &user_id, Some(room_id))
if !share_encrypted_room(services, sender_user, user_id, Some(room_id))
.await
{
device_list_updates.insert(user_id);
device_list_updates.insert(user_id.into());
}
},
| MembershipState::Leave => {
// Write down users that have left encrypted rooms we are in
left_encrypted_users.insert(user_id);
left_encrypted_users.insert(user_id.into());
},
| _ => {},
}

View file

@ -30,7 +30,7 @@ use ruma::{
TimelineEventType::{self, *},
},
serde::Raw,
uint, MilliSecondsSinceUnixEpoch, OwnedEventId, OwnedRoomId, UInt, UserId,
uint, MilliSecondsSinceUnixEpoch, OwnedEventId, OwnedRoomId, OwnedUserId, UInt,
};
use service::{rooms::read_receipt::pack_receipts, Services};
@ -243,7 +243,7 @@ pub(crate) async fn sync_events_v4_route(
if pdu.kind == RoomMember {
if let Some(state_key) = &pdu.state_key {
let user_id =
UserId::parse(state_key.clone()).map_err(|_| {
OwnedUserId::parse(state_key.clone()).map_err(|_| {
Error::bad_database("Invalid UserId in member PDU.")
})?;