From f091d3a732ec432e803c06d9f0becffad782affb Mon Sep 17 00:00:00 2001 From: Ginger Date: Fri, 8 May 2026 11:48:20 -0400 Subject: [PATCH] fix: Correctly check for local users' existence --- src/admin/federation/commands.rs | 4 ---- src/service/rooms/membership/mod.rs | 3 ++- src/service/users/mod.rs | 6 ++++-- 3 files changed, 6 insertions(+), 7 deletions(-) diff --git a/src/admin/federation/commands.rs b/src/admin/federation/commands.rs index 34abada33..bad1c403b 100644 --- a/src/admin/federation/commands.rs +++ b/src/admin/federation/commands.rs @@ -102,10 +102,6 @@ pub(super) async fn remote_user_in_rooms(&self, user_id: OwnedUserId) -> Result ); } - if !self.services.users.exists(&user_id).await { - return Err!("Remote user does not exist in our database.",); - } - let mut rooms: Vec<(OwnedRoomId, u64, String)> = self .services .rooms diff --git a/src/service/rooms/membership/mod.rs b/src/service/rooms/membership/mod.rs index fcc605181..287cad69a 100644 --- a/src/service/rooms/membership/mod.rs +++ b/src/service/rooms/membership/mod.rs @@ -81,7 +81,8 @@ impl crate::Service for Service { state: args.depend::("rooms::state"), state_accessor: args.depend::("rooms::state_accessor"), state_cache: args.depend::("rooms::state_cache"), - state_compressor: args.depend::("rooms::state_compressor"), + state_compressor: args + .depend::("rooms::state_compressor"), timeline: args.depend::("rooms::timeline"), users: args.depend::("users"), }, diff --git a/src/service/users/mod.rs b/src/service/users/mod.rs index c9a87f05a..464f042d0 100644 --- a/src/service/users/mod.rs +++ b/src/service/users/mod.rs @@ -255,10 +255,12 @@ impl Service { pub async fn unlock_account(&self, user_id: &UserId) { self.db.userid_lock.remove(user_id); } - /// Check if a user has an account on this homeserver. + /// Check if the provided user ID belongs to an existing (possibly + /// deactivated) account on this homeserver. #[inline] pub async fn exists(&self, user_id: &UserId) -> bool { - self.db.userid_password.get(user_id).await.is_ok() + self.services.globals.user_is_local(&user_id) + && self.db.userid_password.get(user_id).await.is_ok() } /// Check if account is deactivated