deps: update deps
This commit is contained in:
@@ -38,7 +38,7 @@ sea-orm = { version = "1", features = [
|
||||
] }
|
||||
figment = { version = "0.10", features = ["toml", "json", "env", "yaml"] }
|
||||
|
||||
axum = "0.7.9"
|
||||
axum = "0.8"
|
||||
uuid = { version = "1.6.0", features = ["v4"] }
|
||||
tracing-subscriber = { version = "0.3", features = ["env-filter", "json"] }
|
||||
sea-orm-migration = { version = "1", features = ["runtime-tokio-rustls"] }
|
||||
@@ -64,7 +64,6 @@ scraper = "0.22.0"
|
||||
leaky-bucket = "1.1.2"
|
||||
serde_with = "3"
|
||||
jwt-authorizer = "0.15.0"
|
||||
axum-auth = "0.7.0"
|
||||
futures = "0.3.31"
|
||||
librqbit-core = "4"
|
||||
qbit-rs = { git = "https://github.com/lonelyhentxi/qbit.git", rev = "72d53138ebe", features = [
|
||||
@@ -91,6 +90,7 @@ async-graphql-axum = "7.0.13"
|
||||
fastrand = "2.3.0"
|
||||
seaography = "1.1.2"
|
||||
quirks_path = "0.1.0"
|
||||
base64 = "0.22.1"
|
||||
|
||||
[dev-dependencies]
|
||||
serial_test = "3"
|
||||
|
||||
138
apps/recorder/config/development.yaml
Normal file
138
apps/recorder/config/development.yaml
Normal file
@@ -0,0 +1,138 @@
|
||||
# Loco configuration file documentation
|
||||
|
||||
# Application logging configuration
|
||||
logger:
|
||||
# Enable or disable logging.
|
||||
enable: true
|
||||
# Enable pretty backtrace (sets RUST_BACKTRACE=1)
|
||||
pretty_backtrace: true
|
||||
# Log level, options: trace, debug, info, warn or error.
|
||||
level: debug
|
||||
# Define the logging format. options: compact, pretty or Json
|
||||
format: compact
|
||||
# By default the logger has filtering only logs that came from your code or logs that came from `loco` framework. to see all third party libraries
|
||||
# Uncomment the line below to override to see all third party libraries you can enable this config and override the logger filters.
|
||||
# override_filter: trace
|
||||
|
||||
# Web server configuration
|
||||
server:
|
||||
# Port on which the server will listen. the server binding is 0.0.0.0:{PORT}
|
||||
port: 5001
|
||||
# The UI hostname or IP address that mailers will point to.
|
||||
host: http://webui.konobangu.com
|
||||
# Out of the box middleware configuration. to disable middleware you can changed the `enable` field to `false` of comment the middleware block
|
||||
middlewares:
|
||||
# Enable Etag cache header middleware
|
||||
etag:
|
||||
enable: true
|
||||
# Allows to limit the payload size request. payload that bigger than this file will blocked the request.
|
||||
limit_payload:
|
||||
# Enable/Disable the middleware.
|
||||
enable: true
|
||||
# the limit size. can be b,kb,kib,mb,mib,gb,gib
|
||||
body_limit: 5mb
|
||||
# Generating a unique request ID and enhancing logging with additional information such as the start and completion of request processing, latency, status code, and other request details.
|
||||
logger:
|
||||
# Enable/Disable the middleware.
|
||||
enable: true
|
||||
# when your code is panicked, the request still returns 500 status code.
|
||||
catch_panic:
|
||||
# Enable/Disable the middleware.
|
||||
enable: true
|
||||
# Timeout for incoming requests middleware. requests that take more time from the configuration will cute and 408 status code will returned.
|
||||
timeout_request:
|
||||
# Enable/Disable the middleware.
|
||||
enable: false
|
||||
# Duration time in milliseconds.
|
||||
timeout: 5000
|
||||
cors:
|
||||
enable: true
|
||||
# Set the value of the [`Access-Control-Allow-Origin`][mdn] header
|
||||
# allow_origins:
|
||||
# - https://loco.rs
|
||||
# Set the value of the [`Access-Control-Allow-Headers`][mdn] header
|
||||
# allow_headers:
|
||||
# - Content-Type
|
||||
# Set the value of the [`Access-Control-Allow-Methods`][mdn] header
|
||||
# allow_methods:
|
||||
# - POST
|
||||
# Set the value of the [`Access-Control-Max-Age`][mdn] header in seconds
|
||||
# max_age: 3600
|
||||
fallback:
|
||||
enable: false
|
||||
|
||||
# Worker Configuration
|
||||
workers:
|
||||
# specifies the worker mode. Options:
|
||||
# - BackgroundQueue - Workers operate asynchronously in the background, processing queued.
|
||||
# - ForegroundBlocking - Workers operate in the foreground and block until tasks are completed.
|
||||
# - BackgroundAsync - Workers operate asynchronously in the background, processing tasks with async capabilities.
|
||||
mode: BackgroundQueue
|
||||
|
||||
# Mailer Configuration.
|
||||
mailer:
|
||||
# SMTP mailer configuration.
|
||||
smtp:
|
||||
# Enable/Disable smtp mailer.
|
||||
enable: true
|
||||
# SMTP server host. e.x localhost, smtp.gmail.com
|
||||
host: '{{ get_env(name="MAILER_HOST", default="localhost") }}'
|
||||
# SMTP server port
|
||||
port: 1025
|
||||
# Use secure connection (SSL/TLS).
|
||||
secure: false
|
||||
# auth:
|
||||
# user:
|
||||
# password:
|
||||
|
||||
# Database Configuration
|
||||
database:
|
||||
# Database connection URI
|
||||
uri: '{{ get_env(name="DATABASE_URL", default="postgres://konobangu:konobangu@127.0.0.1:5432/konobangu") }}'
|
||||
# When enabled, the sql query will be logged.
|
||||
enable_logging: true
|
||||
# Set the timeout duration when acquiring a connection.
|
||||
connect_timeout: 500
|
||||
# Set the idle duration before closing a connection.
|
||||
idle_timeout: 500
|
||||
# Minimum number of connections for a pool.
|
||||
min_connections: 1
|
||||
# Maximum number of connections for a pool.
|
||||
max_connections: 1
|
||||
# Run migration up when application loaded
|
||||
auto_migrate: true
|
||||
# Truncate database when application loaded. This is a dangerous operation, make sure that you using this flag only on dev environments or test mode
|
||||
dangerously_truncate: false
|
||||
# Recreating schema when application loaded. This is a dangerous operation, make sure that you using this flag only on dev environments or test mode
|
||||
dangerously_recreate: false
|
||||
|
||||
# Redis Configuration
|
||||
redis:
|
||||
# Redis connection URI
|
||||
uri: '{{ get_env(name="REDIS_URL", default="redis://127.0.0.1:6379") }}'
|
||||
# Dangerously flush all data in Redis on startup. dangerous operation, make sure that you using this flag only on dev environments or test mode
|
||||
dangerously_flush: false
|
||||
|
||||
settings:
|
||||
|
||||
dal:
|
||||
data_dir: ./data
|
||||
|
||||
mikan:
|
||||
base_url: "https://mikanani.me/"
|
||||
http_client:
|
||||
exponential_backoff_max_retries: 3
|
||||
leaky_bucket_max_tokens: 2
|
||||
leaky_bucket_initial_tokens: 0
|
||||
leaky_bucket_refill_tokens: 1
|
||||
leaky_bucket_refill_interval: 500
|
||||
|
||||
auth:
|
||||
auth_type: "oidc" # or "basic"
|
||||
basic_user: "konobangu"
|
||||
basic_password: "konobangu"
|
||||
oidc_api_issuer: "https://some-oidc-auth.com/oidc"
|
||||
oidc_api_audience: "https://konobangu.com/api"
|
||||
oidc_extra_scopes: "read:konobangu,write:konobangu"
|
||||
oidc_extra_claim_key: ""
|
||||
oidc_extra_claim_value: ""
|
||||
0
apps/recorder/config/production.yaml
Normal file
0
apps/recorder/config/production.yaml
Normal file
125
apps/recorder/config/test.yaml
Normal file
125
apps/recorder/config/test.yaml
Normal file
@@ -0,0 +1,125 @@
|
||||
# Loco configuration file documentation
|
||||
|
||||
# Application logging configuration
|
||||
logger:
|
||||
# Enable or disable logging.
|
||||
enable: true
|
||||
# Enable pretty backtrace (sets RUST_BACKTRACE=1)
|
||||
pretty_backtrace: true
|
||||
# Log level, options: trace, debug, info, warn or error.
|
||||
level: debug
|
||||
# Define the logging format. options: compact, pretty or Json
|
||||
format: compact
|
||||
# By default the logger has filtering only logs that came from your code or logs that came from `loco` framework. to see all third party libraries
|
||||
# Uncomment the line below to override to see all third party libraries you can enable this config and override the logger filters.
|
||||
# override_filter: trace
|
||||
|
||||
# Web server configuration
|
||||
server:
|
||||
# Port on which the server will listen. the server binding is 0.0.0.0:{PORT}
|
||||
port: 5001
|
||||
# The UI hostname or IP address that mailers will point to.
|
||||
host: http://webui.konobangu.com
|
||||
# Out of the box middleware configuration. to disable middleware you can changed the `enable` field to `false` of comment the middleware block
|
||||
middlewares:
|
||||
# Enable Etag cache header middleware
|
||||
etag:
|
||||
enable: true
|
||||
# Allows to limit the payload size request. payload that bigger than this file will blocked the request.
|
||||
limit_payload:
|
||||
# Enable/Disable the middleware.
|
||||
enable: true
|
||||
# the limit size. can be b,kb,kib,mb,mib,gb,gib
|
||||
body_limit: 5mb
|
||||
# Generating a unique request ID and enhancing logging with additional information such as the start and completion of request processing, latency, status code, and other request details.
|
||||
logger:
|
||||
# Enable/Disable the middleware.
|
||||
enable: true
|
||||
# when your code is panicked, the request still returns 500 status code.
|
||||
catch_panic:
|
||||
# Enable/Disable the middleware.
|
||||
enable: true
|
||||
# Timeout for incoming requests middleware. requests that take more time from the configuration will cute and 408 status code will returned.
|
||||
timeout_request:
|
||||
# Enable/Disable the middleware.
|
||||
enable: false
|
||||
# Duration time in milliseconds.
|
||||
timeout: 5000
|
||||
cors:
|
||||
enable: true
|
||||
# Set the value of the [`Access-Control-Allow-Origin`][mdn] header
|
||||
# allow_origins:
|
||||
# - https://loco.rs
|
||||
# Set the value of the [`Access-Control-Allow-Headers`][mdn] header
|
||||
# allow_headers:
|
||||
# - Content-Type
|
||||
# Set the value of the [`Access-Control-Allow-Methods`][mdn] header
|
||||
# allow_methods:
|
||||
# - POST
|
||||
# Set the value of the [`Access-Control-Max-Age`][mdn] header in seconds
|
||||
# max_age: 3600
|
||||
|
||||
# Worker Configuration
|
||||
workers:
|
||||
# specifies the worker mode. Options:
|
||||
# - BackgroundQueue - Workers operate asynchronously in the background, processing queued.
|
||||
# - ForegroundBlocking - Workers operate in the foreground and block until tasks are completed.
|
||||
# - BackgroundAsync - Workers operate asynchronously in the background, processing tasks with async capabilities.
|
||||
mode: BackgroundQueue
|
||||
|
||||
# Mailer Configuration.
|
||||
mailer:
|
||||
# SMTP mailer configuration.
|
||||
smtp:
|
||||
# Enable/Disable smtp mailer.
|
||||
enable: true
|
||||
# SMTP server host. e.x localhost, smtp.gmail.com
|
||||
host: '{{ get_env(name="MAILER_HOST", default="localhost") }}'
|
||||
# SMTP server port
|
||||
port: 1025
|
||||
# Use secure connection (SSL/TLS).
|
||||
secure: false
|
||||
# auth:
|
||||
# user:
|
||||
# password:
|
||||
|
||||
# Database Configuration
|
||||
database:
|
||||
# Database connection URI
|
||||
uri: '{{ get_env(name="DATABASE_URL", default="postgres://konobangu:konobangu@127.0.0.1:5432/konobangu") }}'
|
||||
# When enabled, the sql query will be logged.
|
||||
enable_logging: true
|
||||
# Set the timeout duration when acquiring a connection.
|
||||
connect_timeout: 500
|
||||
# Set the idle duration before closing a connection.
|
||||
idle_timeout: 500
|
||||
# Minimum number of connections for a pool.
|
||||
min_connections: 1
|
||||
# Maximum number of connections for a pool.
|
||||
max_connections: 1
|
||||
# Run migration up when application loaded
|
||||
auto_migrate: true
|
||||
# Truncate database when application loaded. This is a dangerous operation, make sure that you using this flag only on dev environments or test mode
|
||||
dangerously_truncate: false
|
||||
# Recreating schema when application loaded. This is a dangerous operation, make sure that you using this flag only on dev environments or test mode
|
||||
dangerously_recreate: false
|
||||
|
||||
# Redis Configuration
|
||||
redis:
|
||||
# Redis connection URI
|
||||
uri: '{{ get_env(name="REDIS_URL", default="redis://127.0.0.1:6379") }}'
|
||||
# Dangerously flush all data in Redis on startup. dangerous operation, make sure that you using this flag only on dev environments or test mode
|
||||
dangerously_flush: false
|
||||
|
||||
settings:
|
||||
dal:
|
||||
data_dir: ./temp
|
||||
mikan:
|
||||
http_client:
|
||||
exponential_backoff_max_retries: 3
|
||||
leaky_bucket_max_tokens: 2
|
||||
leaky_bucket_initial_tokens: 0
|
||||
leaky_bucket_refill_tokens: 1
|
||||
leaky_bucket_refill_interval: 500
|
||||
user_agent: "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/131.0.0.0 Safari/537.36 Edg/131.0.0.0"
|
||||
base_url: "https://mikanani.me/"
|
||||
@@ -19,7 +19,6 @@ use recorder::{
|
||||
use sea_orm_migration::MigratorTrait;
|
||||
|
||||
async fn pull_mikan_bangumi_rss(ctx: &AppContext) -> color_eyre::eyre::Result<()> {
|
||||
color_eyre::install()?;
|
||||
let rss_link = "https://mikanani.me/RSS/Bangumi?bangumiId=3416&subgroupid=370";
|
||||
|
||||
// let rss_link =
|
||||
@@ -49,10 +48,7 @@ async fn pull_mikan_bangumi_rss(ctx: &AppContext) -> color_eyre::eyre::Result<()
|
||||
}
|
||||
|
||||
async fn init() -> color_eyre::eyre::Result<AppContext> {
|
||||
tracing_subscriber::fmt()
|
||||
.with_max_level(tracing::Level::INFO)
|
||||
.with_test_writer()
|
||||
.init();
|
||||
color_eyre::install()?;
|
||||
let ctx = loco_rs::cli::playground::<App>().await?;
|
||||
let BootResult {
|
||||
app_context: ctx, ..
|
||||
@@ -66,15 +62,5 @@ async fn main() -> color_eyre::eyre::Result<()> {
|
||||
let ctx = init().await?;
|
||||
pull_mikan_bangumi_rss(&ctx).await?;
|
||||
|
||||
// let active_model: articles::ActiveModel = ActiveModel {
|
||||
// title: Set(Some("how to build apps in 3 steps".to_string())),
|
||||
// content: Set(Some("use Loco: https://loco.rs".to_string())),
|
||||
// ..Default::default()
|
||||
// };
|
||||
// active_model.insert(&ctx.db).await.unwrap();
|
||||
|
||||
// let res = articles::Entity::find().all(&ctx.db).await.unwrap();
|
||||
// println!("{:?}", res);
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
||||
@@ -5,6 +5,7 @@ use loco_rs::{
|
||||
app::{AppContext, Hooks},
|
||||
boot::{create_app, BootResult, StartMode},
|
||||
cache,
|
||||
config::Config,
|
||||
controller::AppRoutes,
|
||||
db::truncate_table,
|
||||
environment::Environment,
|
||||
@@ -25,6 +26,8 @@ use crate::{
|
||||
workers::subscription_worker::SubscriptionWorker,
|
||||
};
|
||||
|
||||
pub const CONFIG_FOLDER: &str = "LOCO_CONFIG_FOLDER";
|
||||
|
||||
pub trait AppContextExt {
|
||||
fn get_dal_client(&self) -> &AppDalClient {
|
||||
AppDalClient::app_instance()
|
||||
@@ -49,6 +52,20 @@ pub struct App;
|
||||
|
||||
#[async_trait]
|
||||
impl Hooks for App {
|
||||
async fn load_config(env: &Environment) -> Result<Config> {
|
||||
std::env::var(CONFIG_FOLDER).map_or_else(
|
||||
|_| {
|
||||
let monorepo_project_config_dir = Path::new("./apps/recorder/config");
|
||||
if monorepo_project_config_dir.exists() && monorepo_project_config_dir.is_dir() {
|
||||
return env.load_from_folder(monorepo_project_config_dir);
|
||||
}
|
||||
let current_config_dir = Path::new("./config");
|
||||
env.load_from_folder(current_config_dir)
|
||||
},
|
||||
|config_folder| env.load_from_folder(Path::new(&config_folder)),
|
||||
)
|
||||
}
|
||||
|
||||
fn app_name() -> &'static str {
|
||||
env!("CARGO_CRATE_NAME")
|
||||
}
|
||||
@@ -73,8 +90,12 @@ impl Hooks for App {
|
||||
)
|
||||
}
|
||||
|
||||
async fn boot(mode: StartMode, environment: &Environment) -> Result<BootResult> {
|
||||
create_app::<Self, Migrator>(mode, environment).await
|
||||
async fn boot(
|
||||
mode: StartMode,
|
||||
environment: &Environment,
|
||||
config: Config,
|
||||
) -> Result<BootResult> {
|
||||
create_app::<Self, Migrator>(mode, environment, config).await
|
||||
}
|
||||
|
||||
fn routes(ctx: &AppContext) -> AppRoutes {
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
use async_trait::async_trait;
|
||||
use axum::{http::request::Parts, RequestPartsExt};
|
||||
use axum_auth::AuthBasic;
|
||||
use axum::http::request::Parts;
|
||||
use base64::{self, Engine};
|
||||
use reqwest::header::AUTHORIZATION;
|
||||
|
||||
use super::{
|
||||
config::BasicAuthConfig,
|
||||
@@ -9,6 +10,48 @@ use super::{
|
||||
};
|
||||
use crate::models::{auth::AuthType, subscribers::SEED_SUBSCRIBER};
|
||||
|
||||
#[derive(Debug, PartialEq, Eq, Clone)]
|
||||
pub struct AuthBasic {
|
||||
pub user: String,
|
||||
pub password: Option<String>,
|
||||
}
|
||||
|
||||
impl AuthBasic {
|
||||
fn decode_request_parts(req: &mut Parts) -> Result<Self, AuthError> {
|
||||
let authorization = req
|
||||
.headers
|
||||
.get(AUTHORIZATION)
|
||||
.and_then(|s| s.to_str().ok())
|
||||
.ok_or_else(|| AuthError::BasicInvalidCredentials)?;
|
||||
|
||||
let split = authorization.split_once(' ');
|
||||
|
||||
match split {
|
||||
Some((name, contents)) if name == "Basic" => {
|
||||
let decoded = base64::engine::general_purpose::STANDARD
|
||||
.decode(contents)
|
||||
.map_err(|_| AuthError::BasicInvalidCredentials)?;
|
||||
|
||||
let decoded =
|
||||
String::from_utf8(decoded).map_err(|_| AuthError::BasicInvalidCredentials)?;
|
||||
|
||||
Ok(if let Some((user, password)) = decoded.split_once(':') {
|
||||
Self {
|
||||
user: String::from(user),
|
||||
password: Some(String::from(password)),
|
||||
}
|
||||
} else {
|
||||
Self {
|
||||
user: decoded,
|
||||
password: None,
|
||||
}
|
||||
})
|
||||
}
|
||||
_ => Err(AuthError::BasicInvalidCredentials),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Debug)]
|
||||
pub struct BasicAuthService {
|
||||
pub config: BasicAuthConfig,
|
||||
@@ -17,7 +60,11 @@ pub struct BasicAuthService {
|
||||
#[async_trait]
|
||||
impl AuthService for BasicAuthService {
|
||||
async fn extract_user_info(&self, request: &mut Parts) -> Result<AuthUserInfo, AuthError> {
|
||||
if let Ok(AuthBasic((found_user, found_password))) = request.extract().await {
|
||||
if let Ok(AuthBasic {
|
||||
user: found_user,
|
||||
password: found_password,
|
||||
}) = AuthBasic::decode_request_parts(request)
|
||||
{
|
||||
if self.config.user == found_user
|
||||
&& self.config.password == found_password.unwrap_or_default()
|
||||
{
|
||||
|
||||
@@ -22,7 +22,6 @@ pub struct AuthUserInfo {
|
||||
pub auth_type: AuthType,
|
||||
}
|
||||
|
||||
#[async_trait]
|
||||
impl<S> FromRequestParts<S> for AuthUserInfo
|
||||
where
|
||||
S: Send + Sync,
|
||||
|
||||
@@ -1,7 +1,10 @@
|
||||
use async_graphql::http::{playground_source, GraphQLPlaygroundConfig};
|
||||
use async_graphql_axum::GraphQL;
|
||||
use axum::response::Html;
|
||||
use loco_rs::prelude::*;
|
||||
use axum::{
|
||||
response::{Html, IntoResponse},
|
||||
routing::{get, post_service},
|
||||
};
|
||||
use loco_rs::prelude::Routes;
|
||||
|
||||
use crate::graphql::service::AppGraphQLService;
|
||||
|
||||
@@ -12,8 +15,11 @@ pub async fn graphql_playground() -> impl IntoResponse {
|
||||
}
|
||||
|
||||
pub fn routes(graphql_service: &AppGraphQLService) -> Routes {
|
||||
Routes::new().prefix("/graphql").add(
|
||||
"/",
|
||||
get(graphql_playground).post_service(GraphQL::new(graphql_service.schema.clone())),
|
||||
)
|
||||
Routes::new()
|
||||
.prefix("/graphql")
|
||||
.add("/playground", get(graphql_playground))
|
||||
.add(
|
||||
"/",
|
||||
post_service(GraphQL::new(graphql_service.schema.clone())),
|
||||
)
|
||||
}
|
||||
|
||||
@@ -15,7 +15,6 @@ pub fn schema(
|
||||
seaography::register_entities!(
|
||||
builder,
|
||||
[
|
||||
auth,
|
||||
bangumi,
|
||||
downloaders,
|
||||
downloads,
|
||||
@@ -28,7 +27,6 @@ pub fn schema(
|
||||
);
|
||||
|
||||
{
|
||||
builder.register_enumeration::<auth::AuthType>();
|
||||
builder.register_enumeration::<downloads::DownloadStatus>();
|
||||
builder.register_enumeration::<subscriptions::SubscriptionCategory>();
|
||||
builder.register_enumeration::<downloaders::DownloaderCategory>();
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
use async_trait::async_trait;
|
||||
use loco_rs::schema::jsonb_null;
|
||||
use sea_orm_migration::{prelude::*, schema::*};
|
||||
|
||||
use super::defs::{
|
||||
@@ -27,7 +26,7 @@ impl MigrationTrait for Migration {
|
||||
.col(pk_auto(Subscribers::Id))
|
||||
.col(string_len_uniq(Subscribers::Pid, 64))
|
||||
.col(string(Subscribers::DisplayName))
|
||||
.col(jsonb_null(Subscribers::BangumiConf))
|
||||
.col(json_binary_null(Subscribers::BangumiConf))
|
||||
.to_owned(),
|
||||
)
|
||||
.await?;
|
||||
@@ -101,13 +100,13 @@ impl MigrationTrait for Migration {
|
||||
.col(text_null(Bangumi::SeasonRaw))
|
||||
.col(text_null(Bangumi::Fansub))
|
||||
.col(text_null(Bangumi::MikanFansubId))
|
||||
.col(jsonb_null(Bangumi::Filter))
|
||||
.col(json_binary_null(Bangumi::Filter))
|
||||
.col(text_null(Bangumi::RssLink))
|
||||
.col(text_null(Bangumi::PosterLink))
|
||||
.col(text_null(Bangumi::SavePath))
|
||||
.col(boolean(Bangumi::Deleted).default(false))
|
||||
.col(text_null(Bangumi::Homepage))
|
||||
.col(jsonb_null(Bangumi::Extra))
|
||||
.col(json_binary_null(Bangumi::Extra))
|
||||
.foreign_key(
|
||||
ForeignKey::create()
|
||||
.name("fk_bangumi_subscriber_id")
|
||||
@@ -214,7 +213,7 @@ impl MigrationTrait for Migration {
|
||||
.col(text_null(Episodes::Subtitle))
|
||||
.col(boolean(Episodes::Deleted).default(false))
|
||||
.col(text_null(Episodes::Source))
|
||||
.col(jsonb_null(Episodes::Extra))
|
||||
.col(json_binary_null(Episodes::Extra))
|
||||
.foreign_key(
|
||||
ForeignKey::create()
|
||||
.name("fk_episodes_bangumi_id")
|
||||
|
||||
@@ -45,11 +45,5 @@ impl Related<super::subscribers::Entity> for Entity {
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Copy, Clone, Debug, EnumIter, DeriveRelatedEntity)]
|
||||
pub enum RelatedEntity {
|
||||
#[sea_orm(entity = "super::subscribers::Entity")]
|
||||
Subscriber,
|
||||
}
|
||||
|
||||
#[async_trait]
|
||||
impl ActiveModelBehavior for ActiveModel {}
|
||||
|
||||
@@ -45,7 +45,7 @@ pub struct Model {
|
||||
pub poster_link: Option<String>,
|
||||
pub episode_index: i32,
|
||||
pub homepage: Option<String>,
|
||||
pub subtitle: Option<Vec<String>>,
|
||||
pub subtitle: Option<String>,
|
||||
#[sea_orm(default = "false")]
|
||||
pub deleted: bool,
|
||||
pub source: Option<String>,
|
||||
@@ -218,7 +218,7 @@ impl ActiveModel {
|
||||
poster_link: ActiveValue::Set(bgm.poster_link.clone()),
|
||||
episode_index: ActiveValue::Set(raw_meta.episode_index),
|
||||
homepage: ActiveValue::Set(Some(homepage.to_string())),
|
||||
subtitle: ActiveValue::Set(raw_meta.subtitle.map(|s| vec![s])),
|
||||
subtitle: ActiveValue::Set(raw_meta.subtitle),
|
||||
source: ActiveValue::Set(raw_meta.source),
|
||||
extra: ActiveValue::Set(EpisodeExtra {
|
||||
name_zh: raw_meta.name_zh,
|
||||
|
||||
@@ -80,8 +80,6 @@ pub enum RelatedEntity {
|
||||
Bangumi,
|
||||
#[sea_orm(entity = "super::episodes::Entity")]
|
||||
Episode,
|
||||
#[sea_orm(entity = "super::auth::Entity")]
|
||||
Auth,
|
||||
}
|
||||
|
||||
#[derive(Debug, Deserialize, Serialize)]
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user