]> Untitled Git - lemmy.git/blob - crates/db_schema/src/source/local_site.rs
a57bf503c350dd88db6cdccc3b755c595acbd2a2
[lemmy.git] / crates / db_schema / src / source / local_site.rs
1 #[cfg(feature = "full")]
2 use crate::schema::local_site;
3 use crate::{
4   newtypes::{LocalSiteId, SiteId},
5   ListingType,
6   RegistrationMode,
7 };
8 use serde::{Deserialize, Serialize};
9 use serde_with::skip_serializing_none;
10 #[cfg(feature = "full")]
11 use ts_rs::TS;
12 use typed_builder::TypedBuilder;
13
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))]
20 /// The local site.
21 pub struct LocalSite {
22   pub id: LocalSiteId,
23   pub site_id: SiteId,
24   /// True if the site is set up.
25   pub site_setup: bool,
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,
62 }
63
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 {
69   #[builder(!default)]
70   pub site_id: SiteId,
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>,
90 }
91
92 #[derive(Clone, Default)]
93 #[cfg_attr(feature = "full", derive(AsChangeset))]
94 #[cfg_attr(feature = "full", diesel(table_name = local_site))]
95 pub struct LocalSiteUpdateForm {
96   pub site_setup: Option<bool>,
97   pub enable_downvotes: Option<bool>,
98   pub enable_nsfw: Option<bool>,
99   pub community_creation_admin_only: Option<bool>,
100   pub require_email_verification: Option<bool>,
101   pub application_question: Option<Option<String>>,
102   pub private_instance: Option<bool>,
103   pub default_theme: Option<String>,
104   pub default_post_listing_type: Option<ListingType>,
105   pub legal_information: Option<Option<String>>,
106   pub hide_modlog_mod_names: Option<bool>,
107   pub application_email_admins: Option<bool>,
108   pub slur_filter_regex: Option<Option<String>>,
109   pub actor_name_max_length: Option<i32>,
110   pub federation_enabled: Option<bool>,
111   pub captcha_enabled: Option<bool>,
112   pub captcha_difficulty: Option<String>,
113   pub registration_mode: Option<RegistrationMode>,
114   pub reports_email_admins: Option<bool>,
115   pub updated: Option<Option<chrono::NaiveDateTime>>,
116 }