refactor
This commit is contained in:
parent
90fd380f70
commit
abdcc6cbc4
1 changed files with 6 additions and 362 deletions
|
@ -66,7 +66,8 @@ fn read_default_yml() -> Result<HashMap<String, Yaml>, ReadYamlConfigError> {
|
|||
Ok(res)
|
||||
}
|
||||
|
||||
#[derive(Debug)]
|
||||
#[derive(sqlx::FromRow, Debug)]
|
||||
#[sqlx(rename_all = "camelCase")]
|
||||
struct Meta {
|
||||
name: Option<String>,
|
||||
description: Option<String>,
|
||||
|
@ -164,368 +165,11 @@ async fn read_meta_table(
|
|||
.connect()
|
||||
.await?;
|
||||
|
||||
let (
|
||||
name,
|
||||
description,
|
||||
maintainer_name,
|
||||
maintainer_email,
|
||||
disable_registration,
|
||||
disable_local_timeline,
|
||||
disable_global_timeline,
|
||||
banner_url,
|
||||
error_image_url,
|
||||
icon_url,
|
||||
cache_remote_files,
|
||||
enable_recaptcha,
|
||||
recaptcha_site_key,
|
||||
recaptcha_secret_key,
|
||||
local_drive_capacity_mb,
|
||||
): (
|
||||
Option<String>,
|
||||
Option<String>,
|
||||
Option<String>,
|
||||
Option<String>,
|
||||
bool,
|
||||
bool,
|
||||
bool,
|
||||
Option<String>,
|
||||
Option<String>,
|
||||
Option<String>,
|
||||
bool,
|
||||
bool,
|
||||
Option<String>,
|
||||
Option<String>,
|
||||
i32,
|
||||
) = sqlx::query_as(
|
||||
r#"
|
||||
SELECT
|
||||
"name",
|
||||
"description",
|
||||
"maintainerName",
|
||||
"maintainerEmail",
|
||||
"disableRegistration",
|
||||
"disableLocalTimeline",
|
||||
"disableGlobalTimeline",
|
||||
"bannerUrl",
|
||||
"errorImageUrl",
|
||||
"iconUrl",
|
||||
"cacheRemoteFiles",
|
||||
"enableRecaptcha",
|
||||
"recaptchaSiteKey",
|
||||
"recaptchaSecretKey",
|
||||
"localDriveCapacityMb"
|
||||
FROM
|
||||
"meta"
|
||||
"#,
|
||||
)
|
||||
.fetch_one(&mut conn)
|
||||
.await?;
|
||||
let meta: Meta = sqlx::query_as(r#"SELECT * FROM "meta""#)
|
||||
.fetch_one(&mut conn)
|
||||
.await?;
|
||||
|
||||
let (
|
||||
remote_drive_capacity_mb,
|
||||
summaly_proxy,
|
||||
enable_email,
|
||||
email,
|
||||
smtp_secure,
|
||||
smtp_host,
|
||||
smtp_port,
|
||||
smtp_user,
|
||||
smtp_pass,
|
||||
enable_service_worker,
|
||||
sw_public_key,
|
||||
sw_private_key,
|
||||
pinned_users,
|
||||
tos_url,
|
||||
repository_url,
|
||||
): (
|
||||
i32,
|
||||
Option<String>,
|
||||
bool,
|
||||
Option<String>,
|
||||
bool,
|
||||
Option<String>,
|
||||
Option<i32>,
|
||||
Option<String>,
|
||||
Option<String>,
|
||||
bool,
|
||||
Option<String>,
|
||||
Option<String>,
|
||||
Vec<String>,
|
||||
Option<String>,
|
||||
String,
|
||||
) = sqlx::query_as(
|
||||
r#"
|
||||
SELECT
|
||||
"remoteDriveCapacityMb",
|
||||
"summalyProxy",
|
||||
"enableEmail",
|
||||
"email",
|
||||
"smtpSecure",
|
||||
"smtpHost",
|
||||
"smtpPort",
|
||||
"smtpUser",
|
||||
"smtpPass",
|
||||
"enableServiceWorker",
|
||||
"swPublicKey",
|
||||
"swPrivateKey",
|
||||
"pinnedUsers",
|
||||
"tosUrl",
|
||||
"repositoryUrl"
|
||||
FROM
|
||||
"meta"
|
||||
"#,
|
||||
)
|
||||
.fetch_one(&mut conn)
|
||||
.await?;
|
||||
|
||||
let (
|
||||
feedback_url,
|
||||
use_object_storage,
|
||||
object_storage_bucket,
|
||||
object_storage_prefix,
|
||||
object_storage_base_url,
|
||||
object_storage_endpoint,
|
||||
object_storage_region,
|
||||
object_storage_access_key,
|
||||
object_storage_secret_key,
|
||||
object_storage_port,
|
||||
object_storage_use_ssl,
|
||||
object_storage_set_public_read,
|
||||
object_storage_s3_force_path_style,
|
||||
object_storage_use_proxy,
|
||||
proxy_account_id,
|
||||
): (
|
||||
Option<String>,
|
||||
bool,
|
||||
Option<String>,
|
||||
Option<String>,
|
||||
Option<String>,
|
||||
Option<String>,
|
||||
Option<String>,
|
||||
Option<String>,
|
||||
Option<String>,
|
||||
Option<i32>,
|
||||
bool,
|
||||
bool,
|
||||
bool,
|
||||
bool,
|
||||
Option<String>,
|
||||
) = sqlx::query_as(
|
||||
r#"
|
||||
SELECT
|
||||
"feedbackUrl",
|
||||
"useObjectStorage",
|
||||
"objectStorageBucket",
|
||||
"objectStoragePrefix",
|
||||
"objectStorageBaseUrl",
|
||||
"objectStorageEndpoint",
|
||||
"objectStorageRegion",
|
||||
"objectStorageAccessKey",
|
||||
"objectStorageSecretKey",
|
||||
"objectStoragePort",
|
||||
"objectStorageUseSsl",
|
||||
"objectStorageSetPublicRead",
|
||||
"objectStorageS3ForcePathStyle",
|
||||
"objectStorageUseProxy",
|
||||
"proxyAccountId"
|
||||
FROM
|
||||
"meta"
|
||||
"#,
|
||||
)
|
||||
.fetch_one(&mut conn)
|
||||
.await?;
|
||||
|
||||
let (
|
||||
enable_hcaptcha,
|
||||
hcaptcha_site_key,
|
||||
hcaptcha_secret_key,
|
||||
background_image_url,
|
||||
logo_image_url,
|
||||
pinned_clip_id,
|
||||
allowed_hosts,
|
||||
secure_mode,
|
||||
private_mode,
|
||||
deepl_auth_key,
|
||||
deepl_is_pro,
|
||||
email_required_for_signup,
|
||||
theme_color,
|
||||
default_light_theme,
|
||||
default_dark_theme,
|
||||
): (
|
||||
bool,
|
||||
Option<String>,
|
||||
Option<String>,
|
||||
Option<String>,
|
||||
Option<String>,
|
||||
Option<String>,
|
||||
Vec<String>,
|
||||
bool,
|
||||
bool,
|
||||
Option<String>,
|
||||
bool,
|
||||
bool,
|
||||
Option<String>,
|
||||
Option<String>,
|
||||
Option<String>,
|
||||
) = sqlx::query_as(
|
||||
r#"
|
||||
SELECT
|
||||
"enableHcaptcha",
|
||||
"hcaptchaSiteKey",
|
||||
"hcaptchaSecretKey",
|
||||
"backgroundImageUrl",
|
||||
"logoImageUrl",
|
||||
"pinnedClipId",
|
||||
"allowedHosts",
|
||||
"secureMode",
|
||||
"privateMode",
|
||||
"deeplAuthKey",
|
||||
"deeplIsPro",
|
||||
"emailRequiredForSignup",
|
||||
"themeColor",
|
||||
"defaultLightTheme",
|
||||
"defaultDarkTheme"
|
||||
FROM
|
||||
"meta"
|
||||
"#,
|
||||
)
|
||||
.fetch_one(&mut conn)
|
||||
.await?;
|
||||
|
||||
let (
|
||||
enable_ip_logging,
|
||||
enable_active_email_validation,
|
||||
custom_motd,
|
||||
custom_splash_icons,
|
||||
disable_recommended_timeline,
|
||||
recommended_instances,
|
||||
enable_guest_timeline,
|
||||
default_reaction,
|
||||
libre_translate_api_url,
|
||||
libre_translate_api_key,
|
||||
enable_server_machine_stats,
|
||||
enable_identicon_generation,
|
||||
donation_link,
|
||||
mark_local_files_nsfw_by_default,
|
||||
antenna_limit,
|
||||
): (
|
||||
bool,
|
||||
bool,
|
||||
Vec<String>,
|
||||
Vec<String>,
|
||||
bool,
|
||||
Vec<String>,
|
||||
bool,
|
||||
String,
|
||||
Option<String>,
|
||||
Option<String>,
|
||||
bool,
|
||||
bool,
|
||||
Option<String>,
|
||||
bool,
|
||||
i32,
|
||||
) = sqlx::query_as(
|
||||
r#"
|
||||
SELECT
|
||||
"enableIpLogging",
|
||||
"enableActiveEmailValidation",
|
||||
"customMotd",
|
||||
"customSplashIcons",
|
||||
"disableRecommendedTimeline",
|
||||
"recommendedInstances",
|
||||
"enableGuestTimeline",
|
||||
"defaultReaction",
|
||||
"libreTranslateApiUrl",
|
||||
"libreTranslateApiKey",
|
||||
"enableServerMachineStats",
|
||||
"enableIdenticonGeneration",
|
||||
"donationLink",
|
||||
"markLocalFilesNsfwByDefault",
|
||||
"antennaLimit"
|
||||
FROM
|
||||
"meta"
|
||||
"#,
|
||||
)
|
||||
.fetch_one(&mut conn)
|
||||
.await?;
|
||||
|
||||
Ok(Meta {
|
||||
name,
|
||||
description,
|
||||
maintainer_name,
|
||||
maintainer_email,
|
||||
disable_registration,
|
||||
disable_local_timeline,
|
||||
disable_global_timeline,
|
||||
banner_url,
|
||||
error_image_url,
|
||||
icon_url,
|
||||
cache_remote_files,
|
||||
enable_recaptcha,
|
||||
recaptcha_site_key,
|
||||
recaptcha_secret_key,
|
||||
local_drive_capacity_mb,
|
||||
remote_drive_capacity_mb,
|
||||
summaly_proxy,
|
||||
enable_email,
|
||||
email,
|
||||
smtp_secure,
|
||||
smtp_host,
|
||||
smtp_port,
|
||||
smtp_user,
|
||||
smtp_pass,
|
||||
enable_service_worker,
|
||||
sw_public_key,
|
||||
sw_private_key,
|
||||
pinned_users,
|
||||
tos_url,
|
||||
repository_url,
|
||||
feedback_url,
|
||||
use_object_storage,
|
||||
object_storage_bucket,
|
||||
object_storage_prefix,
|
||||
object_storage_base_url,
|
||||
object_storage_endpoint,
|
||||
object_storage_region,
|
||||
object_storage_access_key,
|
||||
object_storage_secret_key,
|
||||
object_storage_port,
|
||||
object_storage_use_ssl,
|
||||
object_storage_set_public_read,
|
||||
object_storage_s3_force_path_style,
|
||||
object_storage_use_proxy,
|
||||
proxy_account_id,
|
||||
enable_hcaptcha,
|
||||
hcaptcha_site_key,
|
||||
hcaptcha_secret_key,
|
||||
background_image_url,
|
||||
logo_image_url,
|
||||
pinned_clip_id,
|
||||
allowed_hosts,
|
||||
secure_mode,
|
||||
private_mode,
|
||||
deepl_auth_key,
|
||||
deepl_is_pro,
|
||||
email_required_for_signup,
|
||||
theme_color,
|
||||
default_light_theme,
|
||||
default_dark_theme,
|
||||
enable_ip_logging,
|
||||
enable_active_email_validation,
|
||||
custom_motd,
|
||||
custom_splash_icons,
|
||||
disable_recommended_timeline,
|
||||
recommended_instances,
|
||||
enable_guest_timeline,
|
||||
default_reaction,
|
||||
libre_translate_api_url,
|
||||
libre_translate_api_key,
|
||||
enable_server_machine_stats,
|
||||
enable_identicon_generation,
|
||||
donation_link,
|
||||
mark_local_files_nsfw_by_default,
|
||||
antenna_limit,
|
||||
})
|
||||
Ok(meta)
|
||||
}
|
||||
|
||||
pub(super) async fn run() -> Result<(), Error> {
|
||||
|
|
Loading…
Reference in a new issue