From ad4f7973cb6676ca1c9fa10441713e98f8e7063b Mon Sep 17 00:00:00 2001 From: Ginger Date: Tue, 7 Jul 2026 10:25:20 -0400 Subject: [PATCH] refactor: Remove `list_local_users` function --- src/admin/user/commands.rs | 4 ++-- src/api/client/unversioned.rs | 2 +- src/service/firstrun/mod.rs | 2 +- src/service/migrations.rs | 6 ++++-- src/service/presence/mod.rs | 2 +- src/service/users/account.rs | 14 +------------- 6 files changed, 10 insertions(+), 20 deletions(-) diff --git a/src/admin/user/commands.rs b/src/admin/user/commands.rs index a76e3fe92..65a637088 100644 --- a/src/admin/user/commands.rs +++ b/src/admin/user/commands.rs @@ -35,7 +35,7 @@ impl crate::Context<'_> { let users: Vec<_> = self .services .users - .list_local_users() + .stream_local_users() .map(|id| id.as_str().to_owned()) .collect() .await; @@ -588,7 +588,7 @@ impl crate::Context<'_> { for user_id in &self .services .users - .list_local_users() + .stream_local_users() .collect::>() .await { diff --git a/src/api/client/unversioned.rs b/src/api/client/unversioned.rs index 63e020350..f49edf724 100644 --- a/src/api/client/unversioned.rs +++ b/src/api/client/unversioned.rs @@ -48,7 +48,7 @@ pub(crate) async fn continuwuity_server_version() -> Result { pub(crate) async fn continuwuity_local_user_count( State(services): State, ) -> Result { - let user_count = services.users.list_local_users().count().await; + let user_count = services.users.stream_local_users().count().await; Ok(Json(serde_json::json!({ "count": user_count diff --git a/src/service/firstrun/mod.rs b/src/service/firstrun/mod.rs index 645a2cb80..85c57d9ce 100644 --- a/src/service/firstrun/mod.rs +++ b/src/service/firstrun/mod.rs @@ -73,7 +73,7 @@ impl crate::Service for Service { && self .services .users - .list_local_users() + .stream_local_users() .ready_filter(|user| *user != self.services.globals.server_user) .next() .await diff --git a/src/service/migrations.rs b/src/service/migrations.rs index f62aa21de..780c52263 100644 --- a/src/service/migrations.rs +++ b/src/service/migrations.rs @@ -315,7 +315,8 @@ async fn migrate(services: &Services) -> Result<()> { async fn db_lt_12(services: &Services) -> Result<()> { for username in &services .users - .list_local_users() + .stream_local_users() + .ready_filter(|user| services.globals.user_is_local(user)) .collect::>() .await { @@ -394,7 +395,8 @@ async fn db_lt_12(services: &Services) -> Result<()> { async fn db_lt_13(services: &Services) -> Result<()> { for username in &services .users - .list_local_users() + .stream_local_users() + .ready_filter(|user| services.globals.user_is_local(user)) .collect::>() .await { diff --git a/src/service/presence/mod.rs b/src/service/presence/mod.rs index 9c89eadd6..d84267057 100644 --- a/src/service/presence/mod.rs +++ b/src/service/presence/mod.rs @@ -182,7 +182,7 @@ impl Service { for user_id in &self .services .users - .list_local_users() + .stream_local_users() .collect::>() .await { diff --git a/src/service/users/account.rs b/src/service/users/account.rs index a12387780..f74c672a1 100644 --- a/src/service/users/account.rs +++ b/src/service/users/account.rs @@ -2,7 +2,7 @@ use std::time::{Duration, SystemTime}; use conduwuit::{ Err, Result, debug_error, debug_warn, err, error, info, trace, - utils::{self, ReadyExt, stream::TryIgnore}, + utils::{self, stream::TryIgnore}, warn, }; use database::{Deserialized, Json}; @@ -557,18 +557,6 @@ impl super::Service { self.db.userid_password.keys().ignore_err() } - /// Returns a list of active local users. - /// - /// A user account is considered `local` if the associated password is not - /// empty. - pub fn list_local_users(&self) -> impl Stream + Send + '_ { - self.db - .userid_password - .stream() - .ignore_err() - .ready_filter_map(|(u, p): (OwnedUserId, &[u8])| (!p.is_empty()).then_some(u)) - } - /// Set a user's password. pub async fn set_password(&self, user_id: &UserId, password: HashedPassword) -> Result { self.status(user_id).await.ensure_active()?;