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