diff --git a/src/api/comment.rs b/src/api/comment.rs index b6b3793..fca9fe6 100644 --- a/src/api/comment.rs +++ b/src/api/comment.rs @@ -112,11 +112,6 @@ pub async fn get_comment(pid: i32, user: CurrentUser, db: Db, rconn: RdsConn) -> })) } -#[post("/docomment")] -pub async fn old_add_comment() -> ApiError { - OldApi.into() -} - #[post("/post//comment", data = "")] pub async fn add_comment( pid: i32, diff --git a/src/api/mod.rs b/src/api/mod.rs index e19ac09..ab53a09 100644 --- a/src/api/mod.rs +++ b/src/api/mod.rs @@ -55,6 +55,11 @@ pub fn catch_403_error() -> &'static str { "可能被封禁了,等下次重置吧" } +#[catch(404)] +pub fn catch_404_error() -> &'static str { + "请更新前端版本" +} + pub struct CurrentUser { pub id: Option, // tmp user has no id, only for block namehash: String, @@ -136,7 +141,6 @@ pub enum PolicyError { InvalidTitle, YouAreTmp, NoReason, - OldApi, UnknownPushEndpoint, } @@ -167,7 +171,6 @@ impl<'r> Responder<'r, 'static> for ApiError { PolicyError::InvalidTitle => "头衔包含不允许的符号", PolicyError::YouAreTmp => "临时用户只可发布内容和进入单个洞", PolicyError::NoReason => "未填写理由", - PolicyError::OldApi => "请使用最新版前端地址并检查更新", PolicyError::UnknownPushEndpoint => "未知的浏览器推送地址", } }) diff --git a/src/api/upload.rs b/src/api/upload.rs index 7043b56..332efe8 100644 --- a/src/api/upload.rs +++ b/src/api/upload.rs @@ -1,14 +1,8 @@ -use super::PolicyError::OldApi; -use super::{ApiError, CurrentUser, JsonApi}; +use super::{CurrentUser, JsonApi}; use rocket::fs::TempFile; use rocket::serde::json::json; use std::env::var; -#[post("/upload")] -pub async fn ipfs_upload() -> ApiError { - OldApi.into() -} - #[post("/upload", data = "")] pub async fn local_upload(_user: CurrentUser, mut file: TempFile<'_>) -> JsonApi { let filename: String = format!( diff --git a/src/main.rs b/src/main.rs index a31952a..99e1e6d 100644 --- a/src/main.rs +++ b/src/main.rs @@ -67,7 +67,6 @@ async fn main() { "/_api/v1", routes![ api::comment::get_comment, - api::comment::old_add_comment, api::post::get_list, api::post::get_one, api::post::publish_post, @@ -82,7 +81,6 @@ async fn main() { api::operation::block, api::operation::set_auto_block, api::vote::vote, - api::upload::ipfs_upload, cors::options_handler, ], ) @@ -107,7 +105,11 @@ async fn main() { ) .register( "/_api", - catchers![api::catch_401_error, api::catch_403_error,], + catchers![ + api::catch_401_error, + api::catch_403_error, + api::catch_404_error + ], ) .manage(RandomHasher::get_random_one()) .manage(rmc)