mirror of
https://github.com/storytold/artcraft.git
synced 2026-11-18 23:55:16 +00:00
refactor: get rid of in-app database::enums module
This commit is contained in:
1 parent
93c5ec0257
commit
fd272a853a
33 files changed
+80
-124
No files matched your search
@@ -1,4 +1,5 @@
|
||||
pub mod job_status;
|
||||
pub mod record_visibility;
|
||||
pub mod tts_model_type;
|
||||
pub mod twitch_event_category;
|
||||
pub mod vocoder_type;
|
||||
File renamed without changes.
@@ -1,3 +1,5 @@
|
||||
//! These denote the pretrained vocoders
|
||||
|
||||
use anyhow::anyhow;
|
||||
use container_common::anyhow_result::AnyhowResult;
|
||||
|
||||
|
||||
@@ -1,3 +0,0 @@
|
||||
pub mod record_visibility;
|
||||
pub mod tts_model_type;
|
||||
pub mod vocoder_type;
|
||||
@@ -1,35 +0,0 @@
|
||||
//! These are columns where users can control the visibility of their data.
|
||||
|
||||
use anyhow::anyhow;
|
||||
use container_common::anyhow_result::AnyhowResult;
|
||||
|
||||
/// To use this in a query, the query must have type annotations.
|
||||
/// See: https://www.gitmemory.com/issue/launchbadge/sqlx/1241/847154375
|
||||
/// eg. preferred_tts_result_visibility as `preferred_tts_result_visibility: crate::database::enums::record_visibility::RecordVisibility`
|
||||
#[derive(Clone, Copy, PartialEq, Eq, Debug, Serialize, Deserialize, sqlx::Type)]
|
||||
#[serde(rename_all = "lowercase")]
|
||||
#[sqlx(rename_all = "lowercase")]
|
||||
pub enum RecordVisibility {
|
||||
Public,
|
||||
Hidden,
|
||||
Private,
|
||||
}
|
||||
|
||||
impl RecordVisibility {
|
||||
pub fn to_str(&self) -> &'static str {
|
||||
match self {
|
||||
RecordVisibility::Public => "public",
|
||||
RecordVisibility::Hidden => "hidden",
|
||||
RecordVisibility::Private => "private",
|
||||
}
|
||||
}
|
||||
|
||||
pub fn from_str(record_visibility: &str) -> AnyhowResult<Self> {
|
||||
match record_visibility {
|
||||
"public" => Ok(RecordVisibility::Public),
|
||||
"hidden" => Ok(RecordVisibility::Hidden),
|
||||
"private" => Ok(RecordVisibility::Private),
|
||||
_ => Err(anyhow!("invalid value: {:?}", record_visibility)),
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,33 +0,0 @@
|
||||
//! These denote the pretrained vocoders
|
||||
|
||||
use anyhow::anyhow;
|
||||
use container_common::anyhow_result::AnyhowResult;
|
||||
|
||||
#[derive(Clone, Copy, PartialEq, Eq, Debug, Serialize, Deserialize, sqlx::Type)]
|
||||
#[serde(rename_all = "lowercase")]
|
||||
#[sqlx(rename_all = "lowercase")]
|
||||
pub enum VocoderType {
|
||||
/// Current state of the art vocoder
|
||||
#[serde(rename = "hifigan-superres")]
|
||||
HifiGanSuperResolution,
|
||||
|
||||
/// Older WaveGlow vocoder
|
||||
WaveGlow,
|
||||
}
|
||||
|
||||
impl VocoderType {
|
||||
pub fn to_str(&self) -> &'static str {
|
||||
match self {
|
||||
VocoderType::HifiGanSuperResolution => "hifigan-superres",
|
||||
VocoderType::WaveGlow => "waveglow",
|
||||
}
|
||||
}
|
||||
|
||||
pub fn from_str(vocoder_type: &str) -> AnyhowResult<Self> {
|
||||
match vocoder_type {
|
||||
"hifigan-superres" => Ok(VocoderType::HifiGanSuperResolution),
|
||||
"waveglow" => Ok(VocoderType::WaveGlow),
|
||||
_ => Err(anyhow!("invalid value: {:?}", vocoder_type)),
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,4 +1,3 @@
|
||||
pub mod enums;
|
||||
pub mod helpers;
|
||||
pub mod mediators;
|
||||
pub mod queries;
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
use anyhow::anyhow;
|
||||
use chrono::{DateTime, Utc};
|
||||
use crate::AnyhowResult;
|
||||
use crate::database::enums::record_visibility::RecordVisibility;
|
||||
use database_queries::column_types::record_visibility::RecordVisibility;
|
||||
use database_queries::helpers::boolean_converters::nullable_i8_to_bool;
|
||||
use log::{info, warn, log};
|
||||
use regex::Regex;
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
use anyhow::anyhow;
|
||||
use chrono::{DateTime, Utc};
|
||||
use crate::AnyhowResult;
|
||||
use crate::database::enums::record_visibility::RecordVisibility;
|
||||
use database_queries::column_types::record_visibility::RecordVisibility;
|
||||
use database_queries::helpers::boolean_converters::{nullable_i8_to_optional_bool, i8_to_bool};
|
||||
use derive_more::{Display, Error};
|
||||
use log::{info, warn, log};
|
||||
|
||||
-1
@@ -1,7 +1,6 @@
|
||||
use anyhow::anyhow;
|
||||
use chrono::{DateTime, Utc};
|
||||
use container_common::anyhow_result::AnyhowResult;
|
||||
use crate::database::enums::record_visibility::RecordVisibility;
|
||||
use database_queries::helpers::boolean_converters::{i8_to_bool, nullable_i8_to_optional_bool};
|
||||
use log::{warn, info};
|
||||
use sqlx::MySqlPool;
|
||||
|
||||
-1
@@ -1,7 +1,6 @@
|
||||
use anyhow::anyhow;
|
||||
use chrono::{DateTime, Utc};
|
||||
use container_common::anyhow_result::AnyhowResult;
|
||||
use crate::database::enums::record_visibility::RecordVisibility;
|
||||
use database_queries::helpers::boolean_converters::{i8_to_bool, nullable_i8_to_optional_bool};
|
||||
use log::{warn, info};
|
||||
use sqlx::MySqlPool;
|
||||
|
||||
+1
-1
@@ -2,7 +2,7 @@ use anyhow::anyhow;
|
||||
use chrono::{DateTime, Utc};
|
||||
use config::shared_constants::DEFAULT_MYSQL_QUERY_RESULT_PAGE_SIZE;
|
||||
use container_common::anyhow_result::AnyhowResult;
|
||||
use crate::database::enums::record_visibility::RecordVisibility;
|
||||
use database_queries::column_types::record_visibility::RecordVisibility;
|
||||
use log::{warn, info};
|
||||
use sqlx::MySqlPool;
|
||||
|
||||
|
||||
+1
-1
@@ -2,7 +2,7 @@ use anyhow::anyhow;
|
||||
use chrono::{DateTime, Utc};
|
||||
use config::shared_constants::DEFAULT_MYSQL_QUERY_RESULT_PAGE_SIZE;
|
||||
use container_common::anyhow_result::AnyhowResult;
|
||||
use crate::database::enums::record_visibility::RecordVisibility;
|
||||
use database_queries::column_types::record_visibility::RecordVisibility;
|
||||
use log::{warn, info};
|
||||
use sqlx::MySqlPool;
|
||||
|
||||
|
||||
-1
@@ -6,7 +6,6 @@ use actix_web::error::ResponseError;
|
||||
use actix_web::http::StatusCode;
|
||||
use actix_web::web::{Path, Json};
|
||||
use actix_web::{Responder, web, HttpResponse, error, HttpRequest};
|
||||
use crate::database::enums::record_visibility::RecordVisibility;
|
||||
use crate::database::queries::query_w2l_template::select_w2l_template_by_token;
|
||||
use crate::http_server::web_utils::ip_address::get_request_ip;
|
||||
use crate::http_server::web_utils::response_error_helpers::to_simple_json_error;
|
||||
|
||||
+1
-3
@@ -7,15 +7,14 @@ use actix_web::http::StatusCode;
|
||||
use actix_web::web::{Path, Json};
|
||||
use actix_web::{Responder, web, HttpResponse, error, HttpRequest};
|
||||
use chrono::{DateTime, Utc};
|
||||
use crate::database::enums::record_visibility::RecordVisibility;
|
||||
use crate::database::queries::query_w2l_template::select_w2l_template_by_token;
|
||||
use crate::database::query_builders::list_categories_query_builder::ListCategoriesQueryBuilder;
|
||||
use crate::http_server::web_utils::ip_address::get_request_ip;
|
||||
use crate::http_server::web_utils::response_error_helpers::to_simple_json_error;
|
||||
use crate::http_server::web_utils::response_success_helpers::simple_json_success;
|
||||
use crate::server_state::ServerState;
|
||||
use crate::util::email_to_gravatar::email_to_gravatar;
|
||||
use crate::util::markdown_to_html::markdown_to_html;
|
||||
use database_queries::api_tokens::list_available_api_tokens_for_user::list_available_api_tokens_for_user;
|
||||
use http_server_common::response::serialize_as_json_error::serialize_as_json_error;
|
||||
use lexical_sort::natural_lexical_cmp;
|
||||
use log::{info, warn, log};
|
||||
@@ -26,7 +25,6 @@ use sqlx::error::Error::Database;
|
||||
use sqlx::mysql::MySqlDatabaseError;
|
||||
use std::fmt;
|
||||
use std::sync::Arc;
|
||||
use database_queries::api_tokens::list_available_api_tokens_for_user::list_available_api_tokens_for_user;
|
||||
|
||||
// =============== Success Response ===============
|
||||
|
||||
|
||||
-1
@@ -7,7 +7,6 @@ use actix_web::http::StatusCode;
|
||||
use actix_web::web::{Path, Json};
|
||||
use actix_web::{Responder, web, HttpResponse, error, HttpRequest};
|
||||
use anyhow::anyhow;
|
||||
use crate::database::enums::record_visibility::RecordVisibility;
|
||||
use crate::database::queries::categories::get_category_by_token::get_category_by_token;
|
||||
use crate::database::queries::query_w2l_template::select_w2l_template_by_token;
|
||||
use crate::http_server::web_utils::ip_address::get_request_ip;
|
||||
|
||||
@@ -6,7 +6,6 @@ use actix_web::error::ResponseError;
|
||||
use actix_web::http::StatusCode;
|
||||
use actix_web::web::{Path, Json};
|
||||
use actix_web::{Responder, web, HttpResponse, error, HttpRequest};
|
||||
use crate::database::enums::record_visibility::RecordVisibility;
|
||||
use crate::database::queries::query_w2l_template::select_w2l_template_by_token;
|
||||
use crate::http_server::web_utils::ip_address::get_request_ip;
|
||||
use crate::http_server::web_utils::response_error_helpers::to_simple_json_error;
|
||||
|
||||
@@ -7,7 +7,6 @@ use actix_web::http::StatusCode;
|
||||
use actix_web::web::{Path, Json};
|
||||
use actix_web::{Responder, web, HttpResponse, error, HttpRequest};
|
||||
use chrono::{DateTime, Utc};
|
||||
use crate::database::enums::record_visibility::RecordVisibility;
|
||||
use crate::database::queries::categories::get_category_by_token::get_category_by_token;
|
||||
use crate::database::queries::query_w2l_template::select_w2l_template_by_token;
|
||||
use crate::database::query_builders::list_categories_query_builder::ListCategoriesQueryBuilder;
|
||||
|
||||
-2
@@ -7,8 +7,6 @@ use actix_web::http::StatusCode;
|
||||
use actix_web::web::{Path, Json};
|
||||
use actix_web::{Responder, web, HttpResponse, error, HttpRequest};
|
||||
use chrono::{DateTime, Utc};
|
||||
use crate::database::enums::record_visibility::RecordVisibility;
|
||||
use crate::database::queries::query_w2l_template::select_w2l_template_by_token;
|
||||
use crate::database::query_builders::list_categories_query_builder::ListCategoriesQueryBuilder;
|
||||
use crate::http_server::web_utils::ip_address::get_request_ip;
|
||||
use crate::http_server::web_utils::response_error_helpers::to_simple_json_error;
|
||||
|
||||
@@ -7,7 +7,6 @@ use actix_web::http::StatusCode;
|
||||
use actix_web::web::{Path, Json};
|
||||
use actix_web::{Responder, web, HttpResponse, error, HttpRequest};
|
||||
use chrono::{DateTime, Utc};
|
||||
use crate::database::enums::record_visibility::RecordVisibility;
|
||||
use crate::database::queries::categories::get_category_by_token::get_category_by_token;
|
||||
use crate::database::queries::query_w2l_template::select_w2l_template_by_token;
|
||||
use crate::database::query_builders::list_categories_query_builder::ListCategoriesQueryBuilder;
|
||||
|
||||
-2
@@ -6,8 +6,6 @@ use actix_web::error::ResponseError;
|
||||
use actix_web::http::StatusCode;
|
||||
use actix_web::web::{Path, Json};
|
||||
use actix_web::{Responder, web, HttpResponse, error, HttpRequest};
|
||||
use crate::database::enums::record_visibility::RecordVisibility;
|
||||
use crate::database::queries::query_w2l_template::select_w2l_template_by_token;
|
||||
use crate::http_server::web_utils::ip_address::get_request_ip;
|
||||
use crate::http_server::web_utils::response_error_helpers::to_simple_json_error;
|
||||
use crate::http_server::web_utils::response_success_helpers::simple_json_success;
|
||||
|
||||
+1
-3
@@ -6,8 +6,7 @@ use actix_web::error::ResponseError;
|
||||
use actix_web::http::StatusCode;
|
||||
use actix_web::web::{Path, Json};
|
||||
use actix_web::{Responder, web, HttpResponse, error, HttpRequest};
|
||||
use crate::database::enums::record_visibility::RecordVisibility;
|
||||
use crate::database::queries::query_w2l_template::select_w2l_template_by_token;
|
||||
use crate::database::queries::categories::get_category_by_token::get_category_by_token;
|
||||
use crate::http_server::web_utils::ip_address::get_request_ip;
|
||||
use crate::http_server::web_utils::response_error_helpers::to_simple_json_error;
|
||||
use crate::http_server::web_utils::response_success_helpers::simple_json_success;
|
||||
@@ -23,7 +22,6 @@ use sqlx::error::Error::Database;
|
||||
use sqlx::mysql::MySqlDatabaseError;
|
||||
use std::fmt;
|
||||
use std::sync::Arc;
|
||||
use crate::database::queries::categories::get_category_by_token::get_category_by_token;
|
||||
|
||||
// =============== Request ===============
|
||||
|
||||
|
||||
-2
@@ -7,8 +7,6 @@ use actix_web::http::StatusCode;
|
||||
use actix_web::web::{Path, Json};
|
||||
use actix_web::{Responder, web, HttpResponse, error, HttpRequest};
|
||||
use chrono::{DateTime, Utc};
|
||||
use crate::database::enums::record_visibility::RecordVisibility;
|
||||
use crate::database::queries::query_w2l_template::select_w2l_template_by_token;
|
||||
use crate::database::query_builders::list_categories_query_builder::ListCategoriesQueryBuilder;
|
||||
use crate::http_server::web_utils::ip_address::get_request_ip;
|
||||
use crate::http_server::web_utils::response_error_helpers::to_simple_json_error;
|
||||
|
||||
@@ -5,7 +5,6 @@ use actix_web::cookie::Cookie;
|
||||
use actix_web::error::ResponseError;
|
||||
use actix_web::http::StatusCode;
|
||||
use actix_web::{Responder, web, HttpResponse, error, HttpRequest};
|
||||
use crate::database::enums::record_visibility::RecordVisibility;
|
||||
use crate::database::helpers::enums::{DownloadUrlType, W2lTemplateType};
|
||||
use crate::http_server::web_utils::ip_address::get_request_ip;
|
||||
use crate::http_server::web_utils::response_error_helpers::to_simple_json_error;
|
||||
@@ -13,8 +12,8 @@ use crate::server_state::ServerState;
|
||||
use crate::validations::model_uploads::validate_model_title;
|
||||
use crate::validations::passwords::validate_passwords;
|
||||
use crate::validations::username::validate_username;
|
||||
use database_queries::column_types::record_visibility::RecordVisibility;
|
||||
use database_queries::tokens::Tokens;
|
||||
use derive_more::{Display, Error};
|
||||
use log::{info, warn, log};
|
||||
use r2d2_redis::redis::Commands;
|
||||
use redis_common::redis_keys::RedisKeys;
|
||||
@@ -22,6 +21,7 @@ use regex::Regex;
|
||||
use sqlx::error::DatabaseError;
|
||||
use sqlx::error::Error::Database;
|
||||
use sqlx::mysql::MySqlDatabaseError;
|
||||
use std::fmt;
|
||||
use std::sync::Arc;
|
||||
use user_input_common::check_for_slurs::contains_slurs;
|
||||
|
||||
@@ -39,7 +39,7 @@ pub struct InferTtsSuccessResponse {
|
||||
pub inference_job_token: String,
|
||||
}
|
||||
|
||||
#[derive(Debug, Display)]
|
||||
#[derive(Debug)]
|
||||
pub enum InferTtsError {
|
||||
BadInput(String),
|
||||
ServerError,
|
||||
@@ -66,6 +66,13 @@ impl ResponseError for InferTtsError {
|
||||
}
|
||||
}
|
||||
|
||||
// NB: Not using derive_more::Display since Clion doesn't understand it.
|
||||
impl fmt::Display for InferTtsError {
|
||||
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
||||
write!(f, "{:?}", self)
|
||||
}
|
||||
}
|
||||
|
||||
pub async fn infer_tts_handler(
|
||||
http_request: HttpRequest,
|
||||
request: web::Json<InferTtsRequest>,
|
||||
|
||||
@@ -6,7 +6,6 @@ use actix_web::error::ResponseError;
|
||||
use actix_web::http::StatusCode;
|
||||
use actix_web::web::Path;
|
||||
use actix_web::{Responder, web, HttpResponse, error, HttpRequest};
|
||||
use crate::database::enums::record_visibility::RecordVisibility;
|
||||
use crate::database::queries::create_session::create_session_for_user;
|
||||
use crate::database::queries::get_user_profile_by_username::get_user_profile_by_username;
|
||||
use crate::http_server::web_utils::ip_address::get_request_ip;
|
||||
@@ -23,12 +22,13 @@ use crate::validations::twitter_username::{validate_twitter_username, normalize_
|
||||
use crate::validations::username::validate_username;
|
||||
use crate::validations::username_reservations::is_reserved_username;
|
||||
use crate::validations::website_url::validate_website_url;
|
||||
use derive_more::{Display, Error};
|
||||
use database_queries::column_types::record_visibility::RecordVisibility;
|
||||
use log::{info, warn, log};
|
||||
use regex::Regex;
|
||||
use sqlx::error::DatabaseError;
|
||||
use sqlx::error::Error::Database;
|
||||
use sqlx::mysql::MySqlDatabaseError;
|
||||
use std::fmt;
|
||||
use std::sync::Arc;
|
||||
use user_input_common::check_for_slurs::contains_slurs;
|
||||
|
||||
@@ -61,7 +61,7 @@ pub struct EditProfileSuccessResponse {
|
||||
pub success: bool,
|
||||
}
|
||||
|
||||
#[derive(Debug, Display)]
|
||||
#[derive(Debug)]
|
||||
pub enum EditProfileError {
|
||||
BadInput(String),
|
||||
NotAuthorized,
|
||||
@@ -91,6 +91,13 @@ impl ResponseError for EditProfileError {
|
||||
}
|
||||
}
|
||||
|
||||
// NB: Not using derive_more::Display since Clion doesn't understand it.
|
||||
impl fmt::Display for EditProfileError {
|
||||
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
||||
write!(f, "{:?}", self)
|
||||
}
|
||||
}
|
||||
|
||||
pub async fn edit_profile_handler(
|
||||
http_request: HttpRequest,
|
||||
path: Path<EditProfilePathInfo>,
|
||||
|
||||
@@ -9,11 +9,11 @@ use actix_web::{Responder, web, HttpResponse, error, HttpRequest, HttpMessage};
|
||||
use anyhow::anyhow;
|
||||
use chrono::{DateTime, Utc};
|
||||
use crate::AnyhowResult;
|
||||
use crate::database::enums::record_visibility::RecordVisibility;
|
||||
use crate::database::queries::list_user_badges::UserBadgeForList;
|
||||
use crate::database::queries::list_user_badges::list_user_badges;
|
||||
use crate::http_server::web_utils::response_error_helpers::to_simple_json_error;
|
||||
use crate::server_state::ServerState;
|
||||
use database_queries::column_types::record_visibility::RecordVisibility;
|
||||
use database_queries::helpers::boolean_converters::i8_to_bool;
|
||||
use log::{info, warn, log};
|
||||
use md5::{Md5, Digest};
|
||||
@@ -160,8 +160,8 @@ SELECT
|
||||
profile_rendered_html,
|
||||
user_role_slug,
|
||||
disable_gravatar,
|
||||
preferred_tts_result_visibility as `preferred_tts_result_visibility: crate::database::enums::record_visibility::RecordVisibility`,
|
||||
preferred_w2l_result_visibility as `preferred_w2l_result_visibility: crate::database::enums::record_visibility::RecordVisibility`,
|
||||
preferred_tts_result_visibility as `preferred_tts_result_visibility: database_queries::column_types::record_visibility::RecordVisibility`,
|
||||
preferred_w2l_result_visibility as `preferred_w2l_result_visibility: database_queries::column_types::record_visibility::RecordVisibility`,
|
||||
discord_username,
|
||||
twitch_username,
|
||||
twitter_username,
|
||||
|
||||
@@ -1,12 +1,11 @@
|
||||
use actix_http::Error;
|
||||
use actix_http::http::header;
|
||||
use actix_web::cookie::Cookie;
|
||||
use actix_web::HttpResponseBuilder;
|
||||
use actix_web::cookie::Cookie;
|
||||
use actix_web::error::ResponseError;
|
||||
use actix_web::http::StatusCode;
|
||||
use actix_web::web::{Path, Json};
|
||||
use actix_web::{Responder, web, HttpResponse, error, HttpRequest};
|
||||
use crate::database::enums::record_visibility::RecordVisibility;
|
||||
use crate::database::queries::query_w2l_result::select_w2l_result_by_token;
|
||||
use crate::http_server::web_utils::ip_address::get_request_ip;
|
||||
use crate::http_server::web_utils::response_error_helpers::to_simple_json_error;
|
||||
@@ -14,13 +13,14 @@ use crate::http_server::web_utils::response_success_helpers::simple_json_success
|
||||
use crate::server_state::ServerState;
|
||||
use crate::util::email_to_gravatar::email_to_gravatar;
|
||||
use crate::util::markdown_to_html::markdown_to_html;
|
||||
use derive_more::{Display, Error};
|
||||
use database_queries::column_types::record_visibility::RecordVisibility;
|
||||
use log::{info, warn, log};
|
||||
use regex::Regex;
|
||||
use sqlx::MySqlPool;
|
||||
use sqlx::error::DatabaseError;
|
||||
use sqlx::error::Error::Database;
|
||||
use sqlx::mysql::MySqlDatabaseError;
|
||||
use std::fmt;
|
||||
use std::sync::Arc;
|
||||
|
||||
/// For the URL PathInfo
|
||||
@@ -35,7 +35,7 @@ pub struct EditW2lResultRequest {
|
||||
pub creator_set_visibility: Option<String>,
|
||||
}
|
||||
|
||||
#[derive(Debug, Display)]
|
||||
#[derive(Debug)]
|
||||
pub enum EditW2lResultError {
|
||||
BadInput(String),
|
||||
NotAuthorized,
|
||||
@@ -65,6 +65,13 @@ impl ResponseError for EditW2lResultError {
|
||||
}
|
||||
}
|
||||
|
||||
// NB: Not using derive_more::Display since Clion doesn't understand it.
|
||||
impl fmt::Display for EditW2lResultError {
|
||||
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
||||
write!(f, "{:?}", self)
|
||||
}
|
||||
}
|
||||
|
||||
pub async fn edit_w2l_inference_result_handler(
|
||||
http_request: HttpRequest,
|
||||
path: Path<EditW2lResultPathInfo>,
|
||||
|
||||
@@ -6,7 +6,6 @@ use actix_web::error::ResponseError;
|
||||
use actix_web::http::StatusCode;
|
||||
use actix_web::web::{Path, Json};
|
||||
use actix_web::{Responder, web, HttpResponse, error, HttpRequest};
|
||||
use crate::database::enums::record_visibility::RecordVisibility;
|
||||
use crate::database::queries::query_w2l_template::select_w2l_template_by_token;
|
||||
use crate::http_server::web_utils::ip_address::get_request_ip;
|
||||
use crate::http_server::web_utils::response_error_helpers::to_simple_json_error;
|
||||
@@ -14,13 +13,14 @@ use crate::http_server::web_utils::response_success_helpers::simple_json_success
|
||||
use crate::server_state::ServerState;
|
||||
use crate::util::email_to_gravatar::email_to_gravatar;
|
||||
use crate::util::markdown_to_html::markdown_to_html;
|
||||
use derive_more::{Display, Error};
|
||||
use database_queries::column_types::record_visibility::RecordVisibility;
|
||||
use log::{info, warn, log};
|
||||
use regex::Regex;
|
||||
use sqlx::MySqlPool;
|
||||
use sqlx::error::DatabaseError;
|
||||
use sqlx::error::Error::Database;
|
||||
use sqlx::mysql::MySqlDatabaseError;
|
||||
use std::fmt;
|
||||
use std::sync::Arc;
|
||||
use user_input_common::check_for_slurs::contains_slurs;
|
||||
|
||||
@@ -46,7 +46,7 @@ pub struct EditW2lTemplateRequest {
|
||||
pub maybe_mod_comments: Option<String>,
|
||||
}
|
||||
|
||||
#[derive(Debug, Display)]
|
||||
#[derive(Debug)]
|
||||
pub enum EditW2lTemplateError {
|
||||
BadInput(String),
|
||||
NotAuthorized,
|
||||
@@ -76,6 +76,13 @@ impl ResponseError for EditW2lTemplateError {
|
||||
}
|
||||
}
|
||||
|
||||
// NB: Not using derive_more::Display since Clion doesn't understand it.
|
||||
impl fmt::Display for EditW2lTemplateError {
|
||||
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
||||
write!(f, "{:?}", self)
|
||||
}
|
||||
}
|
||||
|
||||
pub async fn edit_w2l_template_handler(
|
||||
http_request: HttpRequest,
|
||||
path: Path<EditW2lTemplatePathInfo>,
|
||||
|
||||
@@ -1,11 +1,10 @@
|
||||
use actix_http::Error;
|
||||
use actix_http::http::header;
|
||||
use actix_web::cookie::Cookie;
|
||||
use actix_web::HttpResponseBuilder;
|
||||
use actix_web::cookie::Cookie;
|
||||
use actix_web::error::ResponseError;
|
||||
use actix_web::http::StatusCode;
|
||||
use actix_web::{Responder, web, HttpResponse, error, HttpRequest};
|
||||
use crate::database::enums::record_visibility::RecordVisibility;
|
||||
use crate::database::helpers::enums::{DownloadUrlType, W2lTemplateType};
|
||||
use crate::http_server::web_utils::ip_address::get_request_ip;
|
||||
use crate::http_server::web_utils::response_error_helpers::to_simple_json_error;
|
||||
@@ -13,7 +12,7 @@ use crate::server_state::ServerState;
|
||||
use crate::validations::model_uploads::validate_model_title;
|
||||
use crate::validations::passwords::validate_passwords;
|
||||
use crate::validations::username::validate_username;
|
||||
use derive_more::{Display, Error};
|
||||
use database_queries::column_types::record_visibility::RecordVisibility;
|
||||
use log::{info, warn, log};
|
||||
use r2d2_redis::redis::Commands;
|
||||
use redis_common::redis_keys::RedisKeys;
|
||||
@@ -21,6 +20,7 @@ use regex::Regex;
|
||||
use sqlx::error::DatabaseError;
|
||||
use sqlx::error::Error::Database;
|
||||
use sqlx::mysql::MySqlDatabaseError;
|
||||
use std::fmt;
|
||||
use std::sync::Arc;
|
||||
|
||||
#[derive(Deserialize)]
|
||||
@@ -35,7 +35,7 @@ pub struct InferW2lSuccessResponse {
|
||||
pub success: bool,
|
||||
}
|
||||
|
||||
#[derive(Debug, Display)]
|
||||
#[derive(Debug)]
|
||||
pub enum InferW2lError {
|
||||
BadInput(String),
|
||||
NotAuthorized,
|
||||
@@ -65,6 +65,13 @@ impl ResponseError for InferW2lError {
|
||||
}
|
||||
}
|
||||
|
||||
// NB: Not using derive_more::Display since Clion doesn't understand it.
|
||||
impl fmt::Display for InferW2lError {
|
||||
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
||||
write!(f, "{:?}", self)
|
||||
}
|
||||
}
|
||||
|
||||
pub async fn infer_w2l_handler(
|
||||
http_request: HttpRequest,
|
||||
request: web::Json<InferW2lRequest>,
|
||||
|
||||
+10
-3
@@ -9,7 +9,6 @@ use actix_web::{middleware, web, App, Error, HttpResponse, HttpServer, HttpReque
|
||||
use anyhow::anyhow;
|
||||
use container_common::anyhow_result::AnyhowResult;
|
||||
use container_common::token::random_uuid::generate_random_uuid;
|
||||
use crate::database::enums::record_visibility::RecordVisibility;
|
||||
use crate::http_server::web_utils::ip_address::get_request_ip;
|
||||
use crate::http_server::web_utils::read_multipart_field_bytes::checked_read_multipart_bytes;
|
||||
use crate::http_server::web_utils::read_multipart_field_bytes::read_multipart_field_as_boolean;
|
||||
@@ -19,14 +18,15 @@ use crate::http_server::web_utils::response_error_helpers::to_simple_json_error;
|
||||
use crate::server_state::ServerState;
|
||||
use crate::util::buckets::bucket_client::BucketClient;
|
||||
use crate::util::buckets::bucket_paths::hash_to_bucket_path;
|
||||
use database_queries::column_types::record_visibility::RecordVisibility;
|
||||
use database_queries::tokens::Tokens;
|
||||
use derive_more::{Display, Error};
|
||||
use futures::{StreamExt, TryStreamExt};
|
||||
use log::{warn, info};
|
||||
use r2d2_redis::redis::Commands;
|
||||
use redis_common::redis_keys::RedisKeys;
|
||||
use sqlx::MySqlPool;
|
||||
use sqlx::error::Error::Database;
|
||||
use std::fmt;
|
||||
use std::io::Write;
|
||||
use std::sync::Arc;
|
||||
|
||||
@@ -50,7 +50,7 @@ pub struct InferW2lWithUploadSuccessResponse {
|
||||
pub inference_job_token: String,
|
||||
}
|
||||
|
||||
#[derive(Debug, Display)]
|
||||
#[derive(Debug)]
|
||||
pub enum InferW2lWithUploadError {
|
||||
BadInput(String),
|
||||
EmptyFileUploaded,
|
||||
@@ -80,6 +80,13 @@ impl ResponseError for InferW2lWithUploadError {
|
||||
}
|
||||
}
|
||||
|
||||
// NB: Not using derive_more::Display since Clion doesn't understand it.
|
||||
impl fmt::Display for InferW2lWithUploadError {
|
||||
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
||||
write!(f, "{:?}", self)
|
||||
}
|
||||
}
|
||||
|
||||
/// This handles audio uploads w/ W2L templates.
|
||||
pub async fn enqueue_infer_w2l_with_uploads(
|
||||
http_request: HttpRequest,
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
use actix_web::HttpRequest;
|
||||
use anyhow::anyhow;
|
||||
use crate::AnyhowResult;
|
||||
use crate::database::enums::record_visibility::RecordVisibility;
|
||||
use crate::http_server::web_utils::cookie_manager::CookieManager;
|
||||
use database_queries::column_types::record_visibility::RecordVisibility;
|
||||
use database_queries::helpers::boolean_converters::{nullable_i8_to_optional_bool, i8_to_bool};
|
||||
use log::{info, warn};
|
||||
use sqlx::MySqlPool;
|
||||
@@ -189,8 +189,8 @@ SELECT
|
||||
users.disable_gravatar,
|
||||
users.auto_play_audio_preference,
|
||||
users.auto_play_video_preference,
|
||||
users.preferred_tts_result_visibility as `preferred_tts_result_visibility: crate::database::enums::record_visibility::RecordVisibility`,
|
||||
users.preferred_w2l_result_visibility as `preferred_w2l_result_visibility: crate::database::enums::record_visibility::RecordVisibility`,
|
||||
users.preferred_tts_result_visibility as `preferred_tts_result_visibility: database_queries::column_types::record_visibility::RecordVisibility`,
|
||||
users.preferred_w2l_result_visibility as `preferred_w2l_result_visibility: database_queries::column_types::record_visibility::RecordVisibility`,
|
||||
|
||||
users.user_role_slug,
|
||||
users.is_banned,
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
use anyhow::anyhow;
|
||||
use chrono::{Utc, DateTime};
|
||||
use container_common::anyhow_result::AnyhowResult;
|
||||
use crate::database::enums::record_visibility::RecordVisibility;
|
||||
use database_queries::column_types::record_visibility::RecordVisibility;
|
||||
use database_queries::tokens::Tokens;
|
||||
use log::{warn, info};
|
||||
use sqlx::MySqlPool;
|
||||
@@ -75,7 +75,7 @@ SELECT
|
||||
creator_ip_address,
|
||||
maybe_creator_user_token,
|
||||
|
||||
creator_set_visibility as `creator_set_visibility: crate::database::enums::record_visibility::RecordVisibility`,
|
||||
creator_set_visibility as `creator_set_visibility: database_queries::column_types::record_visibility::RecordVisibility`,
|
||||
disable_end_bump,
|
||||
disable_watermark,
|
||||
|
||||
|
||||
@@ -22,7 +22,6 @@ use config::shared_constants::DEFAULT_MYSQL_CONNECTION_STRING;
|
||||
use config::shared_constants::DEFAULT_RUST_LOG;
|
||||
use container_common::anyhow_result::AnyhowResult;
|
||||
use crate::common_env::CommonEnv;
|
||||
use crate::database::enums::tts_model_type::TtsModelType;
|
||||
use crate::database::mediators::badge_granter::BadgeGranter;
|
||||
use crate::database::mediators::firehose_publisher::FirehosePublisher;
|
||||
use crate::job_queries::tts_download_job_queries::TtsUploadJobRecord;
|
||||
@@ -44,6 +43,7 @@ use crate::util::hashing::hash_file_sha2::hash_file_sha2;
|
||||
use crate::util::noop_logger::NoOpLogger;
|
||||
use crate::util::redis::redis_job_status_logger::RedisJobStatusLogger;
|
||||
use data_encoding::{HEXUPPER, HEXLOWER, HEXLOWER_PERMISSIVE};
|
||||
use database_queries::column_types::tts_model_type::TtsModelType;
|
||||
use log::{warn, info};
|
||||
use r2d2_redis::RedisConnectionManager;
|
||||
use r2d2_redis::r2d2;
|
||||
|
||||
Reference in new issue
Block a user