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))]
|
2023-05-10 19:20:39 +00:00
|
|
|
/// The local site.
|
2022-10-27 09:24:07 +00:00
|
|
|
pub struct LocalSite {
|
|
|
|
pub id: LocalSiteId,
|
|
|
|
pub site_id: SiteId,
|
2023-05-10 19:20:39 +00:00
|
|
|
/// True if the site is set up.
|
2022-10-27 09:24:07 +00:00
|
|
|
pub site_setup: bool,
|
2023-05-10 19:20:39 +00:00
|
|
|
/// Whether downvotes are enabled.
|
2022-10-27 09:24:07 +00:00
|
|
|
pub enable_downvotes: bool,
|
2023-05-10 19:20:39 +00:00
|
|
|
/// Whether NSFW is enabled.
|
2022-10-27 09:24:07 +00:00
|
|
|
pub enable_nsfw: bool,
|
2023-05-10 19:20:39 +00:00
|
|
|
/// Whether only admins can create communities.
|
2022-10-27 09:24:07 +00:00
|
|
|
pub community_creation_admin_only: bool,
|
2023-05-10 19:20:39 +00:00
|
|
|
/// Whether emails are required.
|
2022-10-27 09:24:07 +00:00
|
|
|
pub require_email_verification: bool,
|
2023-05-10 19:20:39 +00:00
|
|
|
/// An optional registration application questionnaire in markdown.
|
2022-10-27 09:24:07 +00:00
|
|
|
pub application_question: Option<String>,
|
2023-05-10 19:20:39 +00:00
|
|
|
/// Whether the instance is private or public.
|
2022-10-27 09:24:07 +00:00
|
|
|
pub private_instance: bool,
|
2023-05-10 19:20:39 +00:00
|
|
|
/// The default front-end theme.
|
2022-10-27 09:24:07 +00:00
|
|
|
pub default_theme: String,
|
2023-04-17 19:19:51 +00:00
|
|
|
pub default_post_listing_type: ListingType,
|
2023-05-10 19:20:39 +00:00
|
|
|
/// An optional legal disclaimer page.
|
2022-10-27 09:24:07 +00:00
|
|
|
pub legal_information: Option<String>,
|
2023-05-10 19:20:39 +00:00
|
|
|
/// Whether to hide mod names on the modlog.
|
2022-10-27 09:24:07 +00:00
|
|
|
pub hide_modlog_mod_names: bool,
|
2023-05-10 19:20:39 +00:00
|
|
|
/// Whether new applications email admins.
|
2022-10-27 09:24:07 +00:00
|
|
|
pub application_email_admins: bool,
|
2023-05-10 19:20:39 +00:00
|
|
|
/// An optional regex to filter words.
|
2022-10-27 09:24:07 +00:00
|
|
|
pub slur_filter_regex: Option<String>,
|
2023-05-10 19:20:39 +00:00
|
|
|
/// The max actor name length.
|
2022-10-27 09:24:07 +00:00
|
|
|
pub actor_name_max_length: i32,
|
2023-05-10 19:20:39 +00:00
|
|
|
/// Whether federation is enabled.
|
2022-10-27 09:24:07 +00:00
|
|
|
pub federation_enabled: bool,
|
2023-05-10 19:20:39 +00:00
|
|
|
/// Whether captcha is enabled.
|
2022-10-27 09:24:07 +00:00
|
|
|
pub captcha_enabled: bool,
|
2023-05-10 19:20:39 +00:00
|
|
|
/// The captcha difficulty.
|
2022-10-27 09:24:07 +00:00
|
|
|
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,
|
2023-05-10 19:20:39 +00:00
|
|
|
/// Whether to email admins on new reports.
|
2023-04-17 19:19:51 +00:00
|
|
|
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 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
|
|
|
}
|
|
|
|
|
2023-08-08 09:41:41 +00:00
|
|
|
#[derive(Clone, Default)]
|
2022-10-27 09:24:07 +00:00
|
|
|
#[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 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>>,
|
|
|
|
}
|