From a394c3f21082f487c96f256cce8a1c9d5e5cafcf Mon Sep 17 00:00:00 2001 From: Kitaiti Makoto Date: Mon, 20 Mar 2023 00:59:46 +0900 Subject: [PATCH] Define admin_search_user route --- src/routes/instance.rs | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/src/routes/instance.rs b/src/routes/instance.rs index b4ac399b..90c0b764 100644 --- a/src/routes/instance.rs +++ b/src/routes/instance.rs @@ -160,7 +160,7 @@ pub fn toggle_block( )) } -#[get("/admin/users?")] +#[get("/admin/users?", rank = 2)] pub fn admin_users( _mod: Moderator, page: Option, @@ -171,6 +171,24 @@ pub fn admin_users( Ok(render!(instance::users( &(&conn, &rockets).to_context(), User::get_local_page(&conn, page.limits())?, + None, + page.0, + Page::total(User::count_local(&conn)? as i32) + ))) +} +#[get("/admin/users?&", rank = 1)] +pub fn admin_search_users( + _mod: Moderator, + user: String, + page: Option, + conn: DbConn, + rockets: PlumeRocket, +) -> Result { + let page = page.unwrap_or_default(); + Ok(render!(instance::users( + &(&conn, &rockets).to_context(), + User::search_local_by_name(&conn, &user, page.limits())?, + Some(user.as_str()), page.0, Page::total(User::count_local(&conn)? as i32) )))