From ffdb0e6f2fb654895b705212e7d29b1338efec3d Mon Sep 17 00:00:00 2001 From: Brandon Thomas Date: Sun, 5 Apr 2026 00:28:08 -0400 Subject: [PATCH] cleanup unimplemented handler --- .../moderation/user_bans/list_banned_users.rs | 111 ------------------ .../endpoints/moderation/user_bans/mod.rs | 3 +- .../application_routes/moderation_routes.rs | 6 - 3 files changed, 1 insertion(+), 119 deletions(-) delete mode 100644 crates/service/web/storyteller_web/src/http_server/endpoints/moderation/user_bans/list_banned_users.rs diff --git a/crates/service/web/storyteller_web/src/http_server/endpoints/moderation/user_bans/list_banned_users.rs b/crates/service/web/storyteller_web/src/http_server/endpoints/moderation/user_bans/list_banned_users.rs deleted file mode 100644 index bba0d7ad31..0000000000 --- a/crates/service/web/storyteller_web/src/http_server/endpoints/moderation/user_bans/list_banned_users.rs +++ /dev/null @@ -1,111 +0,0 @@ -use std::fmt; -use std::sync::Arc; - -use actix_web::error::ResponseError; -use actix_web::http::StatusCode; -use actix_web::{web, HttpRequest, HttpResponse}; -use log::warn; - -use crate::http_server::web_utils::serialize_as_json_error::serialize_as_json_error; -use crate::state::server_state::ServerState; - -// TODO: Implement the endpoint -#[derive(Deserialize)] -pub struct ListBannedUsersRequest; - -// TODO: Implement the endpoint -#[derive(Serialize)] -pub struct ListBannedUsersResponse; - -#[derive(Serialize, Debug)] -pub struct ListBannedUsersErrorResponse { - pub success: bool, - pub error_type: ListBannedUsersErrorType, - pub error_message: String, -} - -#[derive(Copy, Clone, Debug, Serialize)] -pub enum ListBannedUsersErrorType { - BadInput, - ServerError, - Unauthorized, - UserNotFound, -} - -impl ListBannedUsersErrorResponse { - fn unauthorized() -> Self { - Self { - success: false, - error_type: ListBannedUsersErrorType::Unauthorized, - error_message: "unauthorized".to_string() - } - } - fn server_error() -> Self { - Self { - success: false, - error_type: ListBannedUsersErrorType::ServerError, - error_message: "server error".to_string() - } - } - fn bad_request(error_message: &str) -> Self { - Self { - success: false, - error_type: ListBannedUsersErrorType::BadInput, - error_message: error_message.to_string() - } - } -} - -impl ResponseError for ListBannedUsersErrorResponse { - fn status_code(&self) -> StatusCode { - match self.error_type { - ListBannedUsersErrorType::BadInput => StatusCode::BAD_REQUEST, - ListBannedUsersErrorType::ServerError => StatusCode::INTERNAL_SERVER_ERROR, - ListBannedUsersErrorType::Unauthorized => StatusCode::UNAUTHORIZED, - ListBannedUsersErrorType::UserNotFound => StatusCode::NOT_FOUND, - } - } - - fn error_response(&self) -> HttpResponse { - serialize_as_json_error(self) - } -} - -// NB: Not using DeriveMore since Clion doesn't understand it. -impl fmt::Display for ListBannedUsersErrorResponse { - fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { - write!(f, "{:?}", self.error_type) - } -} - -pub async fn list_banned_users_handler( - http_request: HttpRequest, - request: web::Json, - server_state: web::Data> -) -> Result { - - let maybe_user_session = server_state - .session_checker - .maybe_get_user_session(&http_request, &server_state.mysql_pool) - .await - .map_err(|e| { - warn!("Session checker error: {:?}", e); - ListBannedUsersErrorResponse::server_error() - })?; - - let user_session = match maybe_user_session { - Some(session) => session, - None => { - warn!("not logged in"); - return Err(ListBannedUsersErrorResponse::unauthorized()); - } - }; - - if !user_session.can_ban_users { - warn!("user is not allowed to add bans: {:?}", user_session.user_token.as_str()); - return Err(ListBannedUsersErrorResponse::unauthorized()); - } - - // TODO: Implement the endpoint - unimplemented!() -} diff --git a/crates/service/web/storyteller_web/src/http_server/endpoints/moderation/user_bans/mod.rs b/crates/service/web/storyteller_web/src/http_server/endpoints/moderation/user_bans/mod.rs index eec5556ade..513f013b35 100644 --- a/crates/service/web/storyteller_web/src/http_server/endpoints/moderation/user_bans/mod.rs +++ b/crates/service/web/storyteller_web/src/http_server/endpoints/moderation/user_bans/mod.rs @@ -1,2 +1 @@ -pub mod ban_user; -pub mod list_banned_users; \ No newline at end of file +pub mod ban_user; \ No newline at end of file diff --git a/crates/service/web/storyteller_web/src/http_server/routes/application_routes/moderation_routes.rs b/crates/service/web/storyteller_web/src/http_server/routes/application_routes/moderation_routes.rs index 9617cabe44..ae9202618d 100644 --- a/crates/service/web/storyteller_web/src/http_server/routes/application_routes/moderation_routes.rs +++ b/crates/service/web/storyteller_web/src/http_server/routes/application_routes/moderation_routes.rs @@ -30,7 +30,6 @@ use crate::http_server::endpoints::moderation::jobs::get_tts_inference_queue_cou use crate::http_server::endpoints::moderation::jobs::get_w2l_inference_queue_count::get_w2l_inference_queue_count_handler; use crate::http_server::endpoints::moderation::jobs::kill_tts_inference_jobs::kill_tts_inference_jobs_handler; use crate::http_server::endpoints::moderation::user_bans::ban_user::ban_user_handler; -use crate::http_server::endpoints::moderation::user_bans::list_banned_users::list_banned_users_handler; use crate::http_server::endpoints::moderation::user::moderator_list_subscribing_users_by_signup_date::moderator_list_subscribing_users_by_signup_date_handler; use crate::http_server::endpoints::moderation::user::moderator_list_users_by_signup_date::moderator_list_users_by_signup_date_handler; use crate::http_server::endpoints::moderation::user::moderator_user_lookup_by_stripe_customer_id_handler::moderator_user_lookup_by_stripe_customer_id_handler; @@ -158,11 +157,6 @@ pub fn add_moderator_routes (app: App) -> App ) .service( web::scope("/user_bans") - .service( - web::resource("/list") - .route(web::get().to(list_banned_users_handler)) - .route(web::head().to(|| HttpResponse::Ok())) - ) .service( web::resource("/manage_ban") .route(web::post().to(ban_user_handler))