1 #[cfg(feature = "full")]
2 use crate::schema::local_site;
4 newtypes::{LocalSiteId, SiteId},
8 use serde::{Deserialize, Serialize};
9 use serde_with::skip_serializing_none;
10 #[cfg(feature = "full")]
12 use typed_builder::TypedBuilder;
14 #[skip_serializing_none]
15 #[derive(PartialEq, Eq, Debug, Clone, Serialize, Deserialize)]
16 #[cfg_attr(feature = "full", derive(Queryable, Identifiable, TS))]
17 #[cfg_attr(feature = "full", diesel(table_name = local_site))]
18 #[cfg_attr(feature = "full", diesel(belongs_to(crate::source::site::Site)))]
19 #[cfg_attr(feature = "full", ts(export))]
21 pub struct LocalSite {
24 /// True if the site is set up.
26 /// Whether downvotes are enabled.
27 pub enable_downvotes: bool,
28 /// Whether NSFW is enabled.
29 pub enable_nsfw: bool,
30 /// Whether only admins can create communities.
31 pub community_creation_admin_only: bool,
32 /// Whether emails are required.
33 pub require_email_verification: bool,
34 /// An optional registration application questionnaire in markdown.
35 pub application_question: Option<String>,
36 /// Whether the instance is private or public.
37 pub private_instance: bool,
38 /// The default front-end theme.
39 pub default_theme: String,
40 pub default_post_listing_type: ListingType,
41 /// An optional legal disclaimer page.
42 pub legal_information: Option<String>,
43 /// Whether to hide mod names on the modlog.
44 pub hide_modlog_mod_names: bool,
45 /// Whether new applications email admins.
46 pub application_email_admins: bool,
47 /// An optional regex to filter words.
48 pub slur_filter_regex: Option<String>,
49 /// The max actor name length.
50 pub actor_name_max_length: i32,
51 /// Whether federation is enabled.
52 pub federation_enabled: bool,
53 pub federation_debug: bool,
54 /// The number of concurrent federation http workers.
55 pub federation_worker_count: i32,
56 /// Whether captcha is enabled.
57 pub captcha_enabled: bool,
58 /// The captcha difficulty.
59 pub captcha_difficulty: String,
60 pub published: chrono::NaiveDateTime,
61 pub updated: Option<chrono::NaiveDateTime>,
62 pub registration_mode: RegistrationMode,
63 /// Whether to email admins on new reports.
64 pub reports_email_admins: bool,
67 #[derive(Clone, TypedBuilder)]
68 #[builder(field_defaults(default))]
69 #[cfg_attr(feature = "full", derive(Insertable))]
70 #[cfg_attr(feature = "full", diesel(table_name = local_site))]
71 pub struct LocalSiteInsertForm {
74 pub site_setup: Option<bool>,
75 pub enable_downvotes: Option<bool>,
76 pub enable_nsfw: Option<bool>,
77 pub community_creation_admin_only: Option<bool>,
78 pub require_email_verification: Option<bool>,
79 pub application_question: Option<String>,
80 pub private_instance: Option<bool>,
81 pub default_theme: Option<String>,
82 pub default_post_listing_type: Option<ListingType>,
83 pub legal_information: Option<String>,
84 pub hide_modlog_mod_names: Option<bool>,
85 pub application_email_admins: Option<bool>,
86 pub slur_filter_regex: Option<String>,
87 pub actor_name_max_length: Option<i32>,
88 pub federation_enabled: Option<bool>,
89 pub federation_debug: Option<bool>,
90 pub federation_worker_count: Option<i32>,
91 pub captcha_enabled: Option<bool>,
92 pub captcha_difficulty: Option<String>,
93 pub registration_mode: Option<RegistrationMode>,
94 pub reports_email_admins: Option<bool>,
97 #[derive(Clone, TypedBuilder)]
98 #[builder(field_defaults(default))]
99 #[cfg_attr(feature = "full", derive(AsChangeset))]
100 #[cfg_attr(feature = "full", diesel(table_name = local_site))]
101 pub struct LocalSiteUpdateForm {
102 pub site_setup: Option<bool>,
103 pub enable_downvotes: Option<bool>,
104 pub enable_nsfw: Option<bool>,
105 pub community_creation_admin_only: Option<bool>,
106 pub require_email_verification: Option<bool>,
107 pub application_question: Option<Option<String>>,
108 pub private_instance: Option<bool>,
109 pub default_theme: Option<String>,
110 pub default_post_listing_type: Option<ListingType>,
111 pub legal_information: Option<Option<String>>,
112 pub hide_modlog_mod_names: Option<bool>,
113 pub application_email_admins: Option<bool>,
114 pub slur_filter_regex: Option<Option<String>>,
115 pub actor_name_max_length: Option<i32>,
116 pub federation_enabled: Option<bool>,
117 pub federation_debug: Option<bool>,
118 pub federation_worker_count: Option<i32>,
119 pub captcha_enabled: Option<bool>,
120 pub captcha_difficulty: Option<String>,
121 pub registration_mode: Option<RegistrationMode>,
122 pub reports_email_admins: Option<bool>,
123 pub updated: Option<Option<chrono::NaiveDateTime>>,