2022-10-27 09:24:07 +00:00
|
|
|
#[cfg(feature = "full")]
|
|
|
|
use crate::schema::local_site;
|
2023-04-17 19:19:51 +00:00
|
|
|
use crate::{
|
|
|
|
newtypes::{LocalSiteId, SiteId},
|
|
|
|
ListingType,
|
|
|
|
RegistrationMode,
|
|
|
|
};
|
2022-11-02 19:18:22 +00:00
|
|
|
use serde::{Deserialize, Serialize};
|
2023-04-26 04:26:10 +00:00
|
|
|
use serde_with::skip_serializing_none;
|
|
|
|
#[cfg(feature = "full")]
|
|
|
|
use ts_rs::TS;
|
2022-11-02 19:18:22 +00:00
|
|
|
use typed_builder::TypedBuilder;
|
2022-10-27 09:24:07 +00:00
|
|
|
|
2023-04-26 04:26:10 +00:00
|
|
|
#[skip_serializing_none]
|
2022-10-27 09:24:07 +00:00
|
|
|
#[derive(PartialEq, Eq, Debug, Clone, Serialize, Deserialize)]
|
2023-04-26 04:26:10 +00:00
|
|
|
#[cfg_attr(feature = "full", derive(Queryable, Identifiable, TS))]
|
2022-10-27 09:24:07 +00:00
|
|
|
#[cfg_attr(feature = "full", diesel(table_name = local_site))]
|
|
|
|
#[cfg_attr(feature = "full", diesel(belongs_to(crate::source::site::Site)))]
|
2023-04-26 04:26:10 +00:00
|
|
|
#[cfg_attr(feature = "full", ts(export))]
|
2022-10-27 09:24:07 +00:00
|
|
|
pub struct LocalSite {
|
|
|
|
pub id: LocalSiteId,
|
|
|
|
pub site_id: SiteId,
|
|
|
|
pub site_setup: bool,
|
|
|
|
pub enable_downvotes: bool,
|
|
|
|
pub enable_nsfw: bool,
|
|
|
|
pub community_creation_admin_only: bool,
|
|
|
|
pub require_email_verification: bool,
|
|
|
|
pub application_question: Option<String>,
|
|
|
|
pub private_instance: bool,
|
|
|
|
pub default_theme: String,
|
2023-04-17 19:19:51 +00:00
|
|
|
pub default_post_listing_type: ListingType,
|
2022-10-27 09:24:07 +00:00
|
|
|
pub legal_information: Option<String>,
|
|
|
|
pub hide_modlog_mod_names: bool,
|
|
|
|
pub application_email_admins: bool,
|
|
|
|
pub slur_filter_regex: Option<String>,
|
|
|
|
pub actor_name_max_length: i32,
|
|
|
|
pub federation_enabled: bool,
|
|
|
|
pub federation_debug: bool,
|
|
|
|
pub federation_worker_count: i32,
|
|
|
|
pub captcha_enabled: bool,
|
|
|
|
pub captcha_difficulty: String,
|
|
|
|
pub published: chrono::NaiveDateTime,
|
|
|
|
pub updated: Option<chrono::NaiveDateTime>,
|
2023-04-17 19:19:51 +00:00
|
|
|
pub registration_mode: RegistrationMode,
|
|
|
|
pub reports_email_admins: bool,
|
2022-10-27 09:24:07 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
#[derive(Clone, TypedBuilder)]
|
|
|
|
#[builder(field_defaults(default))]
|
|
|
|
#[cfg_attr(feature = "full", derive(Insertable))]
|
|
|
|
#[cfg_attr(feature = "full", diesel(table_name = local_site))]
|
|
|
|
pub struct LocalSiteInsertForm {
|
|
|
|
#[builder(!default)]
|
|
|
|
pub site_id: SiteId,
|
|
|
|
pub site_setup: Option<bool>,
|
|
|
|
pub enable_downvotes: Option<bool>,
|
|
|
|
pub enable_nsfw: Option<bool>,
|
|
|
|
pub community_creation_admin_only: Option<bool>,
|
|
|
|
pub require_email_verification: Option<bool>,
|
|
|
|
pub application_question: Option<String>,
|
|
|
|
pub private_instance: Option<bool>,
|
|
|
|
pub default_theme: Option<String>,
|
2023-04-17 19:19:51 +00:00
|
|
|
pub default_post_listing_type: Option<ListingType>,
|
2022-10-27 09:24:07 +00:00
|
|
|
pub legal_information: Option<String>,
|
|
|
|
pub hide_modlog_mod_names: Option<bool>,
|
|
|
|
pub application_email_admins: Option<bool>,
|
|
|
|
pub slur_filter_regex: Option<String>,
|
|
|
|
pub actor_name_max_length: Option<i32>,
|
|
|
|
pub federation_enabled: Option<bool>,
|
|
|
|
pub federation_debug: Option<bool>,
|
|
|
|
pub federation_worker_count: Option<i32>,
|
|
|
|
pub captcha_enabled: Option<bool>,
|
|
|
|
pub captcha_difficulty: Option<String>,
|
2023-01-05 01:42:30 +00:00
|
|
|
pub registration_mode: Option<RegistrationMode>,
|
2023-02-14 15:57:08 +00:00
|
|
|
pub reports_email_admins: Option<bool>,
|
2022-10-27 09:24:07 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
#[derive(Clone, TypedBuilder)]
|
|
|
|
#[builder(field_defaults(default))]
|
|
|
|
#[cfg_attr(feature = "full", derive(AsChangeset))]
|
|
|
|
#[cfg_attr(feature = "full", diesel(table_name = local_site))]
|
|
|
|
pub struct LocalSiteUpdateForm {
|
|
|
|
pub site_setup: Option<bool>,
|
|
|
|
pub enable_downvotes: Option<bool>,
|
|
|
|
pub enable_nsfw: Option<bool>,
|
|
|
|
pub community_creation_admin_only: Option<bool>,
|
|
|
|
pub require_email_verification: Option<bool>,
|
|
|
|
pub application_question: Option<Option<String>>,
|
|
|
|
pub private_instance: Option<bool>,
|
|
|
|
pub default_theme: Option<String>,
|
2023-04-17 19:19:51 +00:00
|
|
|
pub default_post_listing_type: Option<ListingType>,
|
2022-10-27 09:24:07 +00:00
|
|
|
pub legal_information: Option<Option<String>>,
|
|
|
|
pub hide_modlog_mod_names: Option<bool>,
|
|
|
|
pub application_email_admins: Option<bool>,
|
|
|
|
pub slur_filter_regex: Option<Option<String>>,
|
|
|
|
pub actor_name_max_length: Option<i32>,
|
|
|
|
pub federation_enabled: Option<bool>,
|
|
|
|
pub federation_debug: Option<bool>,
|
|
|
|
pub federation_worker_count: Option<i32>,
|
|
|
|
pub captcha_enabled: Option<bool>,
|
|
|
|
pub captcha_difficulty: Option<String>,
|
2023-01-05 01:42:30 +00:00
|
|
|
pub registration_mode: Option<RegistrationMode>,
|
2023-02-14 15:57:08 +00:00
|
|
|
pub reports_email_admins: Option<bool>,
|
2022-10-27 09:24:07 +00:00
|
|
|
pub updated: Option<Option<chrono::NaiveDateTime>>,
|
|
|
|
}
|