You've already forked AstralRinth
forked from didirus/AstralRinth
Moderation + Mod Editing (#101)
* Moderation + Mod Editing WIP * Run prepare, fix perms * Make it compile * Finish moderation and edit routes * More fixes * Use better queries * Final Fixes
This commit is contained in:
@@ -3,6 +3,7 @@ use actix_web::web;
|
||||
mod auth;
|
||||
mod index;
|
||||
mod mod_creation;
|
||||
mod moderation;
|
||||
mod mods;
|
||||
mod not_found;
|
||||
mod tags;
|
||||
@@ -16,6 +17,7 @@ pub use tags::config as tags_config;
|
||||
|
||||
pub use self::index::index_get;
|
||||
pub use self::not_found::not_found;
|
||||
use crate::file_hosting::FileHostingError;
|
||||
|
||||
pub fn mods_config(cfg: &mut web::ServiceConfig) {
|
||||
cfg.service(mods::mod_search);
|
||||
@@ -26,6 +28,7 @@ pub fn mods_config(cfg: &mut web::ServiceConfig) {
|
||||
web::scope("mod")
|
||||
.service(mods::mod_get)
|
||||
.service(mods::mod_delete)
|
||||
.service(mods::mod_edit)
|
||||
.service(web::scope("{mod_id}").service(versions::version_list)),
|
||||
);
|
||||
}
|
||||
@@ -37,7 +40,13 @@ pub fn versions_config(cfg: &mut web::ServiceConfig) {
|
||||
web::scope("version")
|
||||
.service(versions::version_get)
|
||||
.service(versions::version_delete)
|
||||
.service(version_creation::upload_file_to_version),
|
||||
.service(version_creation::upload_file_to_version)
|
||||
.service(versions::version_edit),
|
||||
);
|
||||
cfg.service(
|
||||
web::scope("version_file")
|
||||
.service(versions::delete_file)
|
||||
.service(versions::get_version_from_hash),
|
||||
);
|
||||
}
|
||||
|
||||
@@ -67,6 +76,8 @@ pub fn teams_config(cfg: &mut web::ServiceConfig) {
|
||||
|
||||
#[derive(thiserror::Error, Debug)]
|
||||
pub enum ApiError {
|
||||
#[error("Error while uploading file")]
|
||||
FileHostingError(#[from] FileHostingError),
|
||||
#[error("Internal server error")]
|
||||
DatabaseError(#[from] crate::database::models::DatabaseError),
|
||||
#[error("Deserialization error: {0}")]
|
||||
@@ -89,6 +100,7 @@ impl actix_web::ResponseError for ApiError {
|
||||
ApiError::CustomAuthenticationError(..) => actix_web::http::StatusCode::UNAUTHORIZED,
|
||||
ApiError::JsonError(..) => actix_web::http::StatusCode::BAD_REQUEST,
|
||||
ApiError::SearchError(..) => actix_web::http::StatusCode::INTERNAL_SERVER_ERROR,
|
||||
ApiError::FileHostingError(..) => actix_web::http::StatusCode::INTERNAL_SERVER_ERROR,
|
||||
ApiError::InvalidInputError(..) => actix_web::http::StatusCode::BAD_REQUEST,
|
||||
}
|
||||
}
|
||||
@@ -102,6 +114,7 @@ impl actix_web::ResponseError for ApiError {
|
||||
ApiError::CustomAuthenticationError(..) => "unauthorized",
|
||||
ApiError::JsonError(..) => "json_error",
|
||||
ApiError::SearchError(..) => "search_error",
|
||||
ApiError::FileHostingError(..) => "file_hosting_error",
|
||||
ApiError::InvalidInputError(..) => "invalid_input",
|
||||
},
|
||||
description: &self.to_string(),
|
||||
|
||||
Reference in New Issue
Block a user