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 /// The number of concurrent federation http workers.
54 pub federation_worker_count: i32,
55 /// Whether captcha is enabled.
56 pub captcha_enabled: bool,
57 /// The captcha difficulty.
58 pub captcha_difficulty: String,
59 pub published: chrono::NaiveDateTime,
60 pub updated: Option<chrono::NaiveDateTime>,
61 pub registration_mode: RegistrationMode,
62 /// Whether to email admins on new reports.
63 pub reports_email_admins: bool,
66 #[derive(Clone, TypedBuilder)]
67 #[builder(field_defaults(default))]
68 #[cfg_attr(feature = "full", derive(Insertable))]
69 #[cfg_attr(feature = "full", diesel(table_name = local_site))]
70 pub struct LocalSiteInsertForm {
73 pub site_setup: Option<bool>,
74 pub enable_downvotes: Option<bool>,
75 pub enable_nsfw: Option<bool>,
76 pub community_creation_admin_only: Option<bool>,
77 pub require_email_verification: Option<bool>,
78 pub application_question: Option<String>,
79 pub private_instance: Option<bool>,
80 pub default_theme: Option<String>,
81 pub default_post_listing_type: Option<ListingType>,
82 pub legal_information: Option<String>,
83 pub hide_modlog_mod_names: Option<bool>,
84 pub application_email_admins: Option<bool>,
85 pub slur_filter_regex: Option<String>,
86 pub actor_name_max_length: Option<i32>,
87 pub federation_enabled: 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 reports_email_admins: Option<bool>,
95 #[derive(Clone, TypedBuilder)]
96 #[builder(field_defaults(default))]
97 #[cfg_attr(feature = "full", derive(AsChangeset))]
98 #[cfg_attr(feature = "full", diesel(table_name = local_site))]
99 pub struct LocalSiteUpdateForm {
100 pub site_setup: Option<bool>,
101 pub enable_downvotes: Option<bool>,
102 pub enable_nsfw: Option<bool>,
103 pub community_creation_admin_only: Option<bool>,
104 pub require_email_verification: Option<bool>,
105 pub application_question: Option<Option<String>>,
106 pub private_instance: Option<bool>,
107 pub default_theme: Option<String>,
108 pub default_post_listing_type: Option<ListingType>,
109 pub legal_information: Option<Option<String>>,
110 pub hide_modlog_mod_names: Option<bool>,
111 pub application_email_admins: Option<bool>,
112 pub slur_filter_regex: Option<Option<String>>,
113 pub actor_name_max_length: Option<i32>,
114 pub federation_enabled: Option<bool>,
115 pub federation_worker_count: Option<i32>,
116 pub captcha_enabled: Option<bool>,
117 pub captcha_difficulty: Option<String>,
118 pub registration_mode: Option<RegistrationMode>,
119 pub reports_email_admins: Option<bool>,
120 pub updated: Option<Option<chrono::NaiveDateTime>>,