1 use crate::newtypes::{LocalSiteId, SiteId};
2 #[cfg(feature = "full")]
3 use crate::schema::local_site;
4 use serde::{Deserialize, Serialize};
5 use typed_builder::TypedBuilder;
7 #[derive(PartialEq, Eq, Debug, Clone, Serialize, Deserialize)]
8 #[cfg_attr(feature = "full", derive(Queryable, Identifiable))]
9 #[cfg_attr(feature = "full", diesel(table_name = local_site))]
10 #[cfg_attr(feature = "full", diesel(belongs_to(crate::source::site::Site)))]
11 pub struct LocalSite {
15 pub enable_downvotes: bool,
16 pub enable_nsfw: bool,
17 pub community_creation_admin_only: bool,
18 pub require_email_verification: bool,
19 pub application_question: Option<String>,
20 pub private_instance: bool,
21 pub default_theme: String,
22 pub default_post_listing_type: String,
23 pub legal_information: Option<String>,
24 pub hide_modlog_mod_names: bool,
25 pub application_email_admins: bool,
26 pub slur_filter_regex: Option<String>,
27 pub actor_name_max_length: i32,
28 pub federation_enabled: bool,
29 pub federation_debug: bool,
30 pub federation_worker_count: i32,
31 pub captcha_enabled: bool,
32 pub captcha_difficulty: String,
33 pub registration_mode: RegistrationMode,
34 pub published: chrono::NaiveDateTime,
35 pub updated: Option<chrono::NaiveDateTime>,
38 #[derive(Clone, TypedBuilder)]
39 #[builder(field_defaults(default))]
40 #[cfg_attr(feature = "full", derive(Insertable))]
41 #[cfg_attr(feature = "full", diesel(table_name = local_site))]
42 pub struct LocalSiteInsertForm {
45 pub site_setup: Option<bool>,
46 pub enable_downvotes: Option<bool>,
47 pub enable_nsfw: Option<bool>,
48 pub community_creation_admin_only: Option<bool>,
49 pub require_email_verification: Option<bool>,
50 pub application_question: Option<String>,
51 pub private_instance: Option<bool>,
52 pub default_theme: Option<String>,
53 pub default_post_listing_type: Option<String>,
54 pub legal_information: Option<String>,
55 pub hide_modlog_mod_names: Option<bool>,
56 pub application_email_admins: Option<bool>,
57 pub slur_filter_regex: Option<String>,
58 pub actor_name_max_length: Option<i32>,
59 pub federation_enabled: Option<bool>,
60 pub federation_debug: Option<bool>,
61 pub federation_worker_count: Option<i32>,
62 pub captcha_enabled: Option<bool>,
63 pub captcha_difficulty: Option<String>,
64 pub registration_mode: Option<RegistrationMode>,
67 #[derive(Clone, TypedBuilder)]
68 #[builder(field_defaults(default))]
69 #[cfg_attr(feature = "full", derive(AsChangeset))]
70 #[cfg_attr(feature = "full", diesel(table_name = local_site))]
71 pub struct LocalSiteUpdateForm {
72 pub site_setup: Option<bool>,
73 pub enable_downvotes: Option<bool>,
74 pub enable_nsfw: Option<bool>,
75 pub community_creation_admin_only: Option<bool>,
76 pub require_email_verification: Option<bool>,
77 pub application_question: Option<Option<String>>,
78 pub private_instance: Option<bool>,
79 pub default_theme: Option<String>,
80 pub default_post_listing_type: Option<String>,
81 pub legal_information: Option<Option<String>>,
82 pub hide_modlog_mod_names: Option<bool>,
83 pub application_email_admins: Option<bool>,
84 pub slur_filter_regex: Option<Option<String>>,
85 pub actor_name_max_length: Option<i32>,
86 pub federation_enabled: Option<bool>,
87 pub federation_debug: Option<bool>,
88 pub federation_worker_count: Option<i32>,
89 pub captcha_enabled: Option<bool>,
90 pub captcha_difficulty: Option<String>,
91 pub registration_mode: Option<RegistrationMode>,
92 pub updated: Option<Option<chrono::NaiveDateTime>>,
95 #[cfg(feature = "full")]
97 #[diesel(postgres_type(name = "registration_mode_enum"))]
98 pub struct RegistrationModeType;
100 #[derive(Clone, Copy, Debug, PartialEq, Eq, Serialize, Deserialize)]
101 #[cfg_attr(feature = "full", derive(FromSqlRow, AsExpression))]
102 #[cfg_attr(feature = "full", diesel(sql_type = RegistrationModeType))]
103 #[serde(rename_all = "lowercase")]
104 pub enum RegistrationMode {