feat: refresh content workflow and verification settings
All checks were successful
docker-images / build-and-push (admin, admin, termi-astro-admin, admin/Dockerfile) (push) Successful in 43s
docker-images / build-and-push (backend, backend, termi-astro-backend, backend/Dockerfile) (push) Successful in 25m9s
docker-images / build-and-push (frontend, frontend, termi-astro-frontend, frontend/Dockerfile) (push) Successful in 51s
All checks were successful
docker-images / build-and-push (admin, admin, termi-astro-admin, admin/Dockerfile) (push) Successful in 43s
docker-images / build-and-push (backend, backend, termi-astro-backend, backend/Dockerfile) (push) Successful in 25m9s
docker-images / build-and-push (frontend, frontend, termi-astro-frontend, frontend/Dockerfile) (push) Successful in 51s
This commit is contained in:
@@ -1,14 +1,12 @@
|
||||
use async_trait::async_trait;
|
||||
use loco_rs::{
|
||||
app::{AppContext, Initializer},
|
||||
Result,
|
||||
app::{AppContext, Initializer},
|
||||
};
|
||||
use sea_orm::{ActiveModelTrait, EntityTrait, IntoActiveModel, QueryOrder, Set};
|
||||
use std::path::{Path, PathBuf};
|
||||
|
||||
use crate::models::_entities::{comments, posts, site_settings};
|
||||
use crate::services::content;
|
||||
|
||||
const FIXTURES_DIR: &str = "src/fixtures";
|
||||
|
||||
pub struct ContentSyncInitializer;
|
||||
@@ -25,7 +23,6 @@ impl Initializer for ContentSyncInitializer {
|
||||
}
|
||||
|
||||
async fn sync_content(ctx: &AppContext, base: &Path) -> Result<()> {
|
||||
content::sync_markdown_posts(ctx).await?;
|
||||
sync_site_settings(ctx, base).await?;
|
||||
sync_comment_post_slugs(ctx, base).await?;
|
||||
Ok(())
|
||||
@@ -111,6 +108,19 @@ async fn sync_site_settings(ctx: &AppContext, base: &Path) -> Result<()> {
|
||||
})
|
||||
.filter(|items| !items.is_empty())
|
||||
.map(serde_json::Value::Array);
|
||||
let comment_verification_mode = as_optional_string(&seed["comment_verification_mode"]);
|
||||
let subscription_verification_mode =
|
||||
as_optional_string(&seed["subscription_verification_mode"]);
|
||||
let comment_turnstile_enabled = seed["comment_turnstile_enabled"]
|
||||
.as_bool()
|
||||
.or(comment_verification_mode
|
||||
.as_deref()
|
||||
.map(|value| value.eq_ignore_ascii_case("turnstile")));
|
||||
let subscription_turnstile_enabled = seed["subscription_turnstile_enabled"]
|
||||
.as_bool()
|
||||
.or(subscription_verification_mode
|
||||
.as_deref()
|
||||
.map(|value| value.eq_ignore_ascii_case("turnstile")));
|
||||
|
||||
let existing = site_settings::Entity::find()
|
||||
.order_by_asc(site_settings::Column::Id)
|
||||
@@ -179,6 +189,24 @@ async fn sync_site_settings(ctx: &AppContext, base: &Path) -> Result<()> {
|
||||
model.paragraph_comments_enabled =
|
||||
Set(seed["paragraph_comments_enabled"].as_bool().or(Some(true)));
|
||||
}
|
||||
if existing.comment_verification_mode.is_none() {
|
||||
model.comment_verification_mode = Set(comment_verification_mode.clone());
|
||||
}
|
||||
if existing.comment_turnstile_enabled.is_none() {
|
||||
model.comment_turnstile_enabled = Set(comment_turnstile_enabled);
|
||||
}
|
||||
if existing.subscription_verification_mode.is_none() {
|
||||
model.subscription_verification_mode = Set(subscription_verification_mode.clone());
|
||||
}
|
||||
if existing.subscription_turnstile_enabled.is_none() {
|
||||
model.subscription_turnstile_enabled = Set(subscription_turnstile_enabled);
|
||||
}
|
||||
if is_blank(&existing.turnstile_site_key) {
|
||||
model.turnstile_site_key = Set(as_optional_string(&seed["turnstile_site_key"]));
|
||||
}
|
||||
if is_blank(&existing.turnstile_secret_key) {
|
||||
model.turnstile_secret_key = Set(as_optional_string(&seed["turnstile_secret_key"]));
|
||||
}
|
||||
if should_upgrade_legacy_ai_defaults {
|
||||
model.ai_provider = Set(as_optional_string(&seed["ai_provider"]));
|
||||
model.ai_api_base = Set(as_optional_string(&seed["ai_api_base"]));
|
||||
@@ -237,6 +265,12 @@ async fn sync_site_settings(ctx: &AppContext, base: &Path) -> Result<()> {
|
||||
paragraph_comments_enabled: Set(seed["paragraph_comments_enabled"]
|
||||
.as_bool()
|
||||
.or(Some(true))),
|
||||
comment_verification_mode: Set(comment_verification_mode),
|
||||
comment_turnstile_enabled: Set(comment_turnstile_enabled),
|
||||
subscription_verification_mode: Set(subscription_verification_mode),
|
||||
subscription_turnstile_enabled: Set(subscription_turnstile_enabled),
|
||||
turnstile_site_key: Set(as_optional_string(&seed["turnstile_site_key"])),
|
||||
turnstile_secret_key: Set(as_optional_string(&seed["turnstile_secret_key"])),
|
||||
ai_provider: Set(as_optional_string(&seed["ai_provider"])),
|
||||
ai_api_base: Set(as_optional_string(&seed["ai_api_base"])),
|
||||
ai_api_key: Set(as_optional_string(&seed["ai_api_key"])),
|
||||
|
||||
Reference in New Issue
Block a user