]> Untitled Git - lemmy.git/blob - crates/db_schema/src/source/local_site.rs
add enable_federated_downvotes site option
[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, RegistrationMode,
6 };
7 use serde::{Deserialize, Serialize};
8 use serde_with::skip_serializing_none;
9 #[cfg(feature = "full")]
10 use ts_rs::TS;
11 use typed_builder::TypedBuilder;
12
13 #[skip_serializing_none]
14 #[derive(PartialEq, Eq, Debug, Clone, Serialize, Deserialize)]
15 #[cfg_attr(feature = "full", derive(Queryable, Identifiable, TS))]
16 #[cfg_attr(feature = "full", diesel(table_name = local_site))]
17 #[cfg_attr(feature = "full", diesel(belongs_to(crate::source::site::Site)))]
18 #[cfg_attr(feature = "full", ts(export))]
19 /// The local site.
20 pub struct LocalSite {
21   pub id: LocalSiteId,
22   pub site_id: SiteId,
23   /// True if the site is set up.
24   pub site_setup: bool,
25   /// Whether downvotes are enabled.
26   pub enable_downvotes: bool,
27   /// Whether downvotes are allowed from federated sites.
28   pub enable_federated_downvotes: bool,
29   /// Whether NSFW is enabled.
30   pub enable_nsfw: bool,
31   /// Whether only admins can create communities.
32   pub community_creation_admin_only: bool,
33   /// Whether emails are required.
34   pub require_email_verification: bool,
35   /// An optional registration application questionnaire in markdown.
36   pub application_question: Option<String>,
37   /// Whether the instance is private or public.
38   pub private_instance: bool,
39   /// The default front-end theme.
40   pub default_theme: String,
41   pub default_post_listing_type: ListingType,
42   /// An optional legal disclaimer page.
43   pub legal_information: Option<String>,
44   /// Whether to hide mod names on the modlog.
45   pub hide_modlog_mod_names: bool,
46   /// Whether new applications email admins.
47   pub application_email_admins: bool,
48   /// An optional regex to filter words.
49   pub slur_filter_regex: Option<String>,
50   /// The max actor name length.
51   pub actor_name_max_length: i32,
52   /// Whether federation is enabled.
53   pub federation_enabled: bool,
54   /// Whether captcha is enabled.
55   pub captcha_enabled: bool,
56   /// The captcha difficulty.
57   pub captcha_difficulty: String,
58   pub published: chrono::NaiveDateTime,
59   pub updated: Option<chrono::NaiveDateTime>,
60   pub registration_mode: RegistrationMode,
61   /// Whether to email admins on new reports.
62   pub reports_email_admins: bool,
63 }
64
65 #[derive(Clone, TypedBuilder)]
66 #[builder(field_defaults(default))]
67 #[cfg_attr(feature = "full", derive(Insertable))]
68 #[cfg_attr(feature = "full", diesel(table_name = local_site))]
69 pub struct LocalSiteInsertForm {
70   #[builder(!default)]
71   pub site_id: SiteId,
72   pub site_setup: Option<bool>,
73   pub enable_downvotes: Option<bool>,
74   pub enable_federated_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 captcha_enabled: Option<bool>,
89   pub captcha_difficulty: Option<String>,
90   pub registration_mode: Option<RegistrationMode>,
91   pub reports_email_admins: Option<bool>,
92 }
93
94 #[derive(Clone, Default)]
95 #[cfg_attr(feature = "full", derive(AsChangeset))]
96 #[cfg_attr(feature = "full", diesel(table_name = local_site))]
97 pub struct LocalSiteUpdateForm {
98   pub site_setup: Option<bool>,
99   pub enable_downvotes: Option<bool>,
100   pub enable_federated_downvotes: Option<bool>,
101   pub enable_nsfw: Option<bool>,
102   pub community_creation_admin_only: Option<bool>,
103   pub require_email_verification: Option<bool>,
104   pub application_question: Option<Option<String>>,
105   pub private_instance: Option<bool>,
106   pub default_theme: Option<String>,
107   pub default_post_listing_type: Option<ListingType>,
108   pub legal_information: Option<Option<String>>,
109   pub hide_modlog_mod_names: Option<bool>,
110   pub application_email_admins: Option<bool>,
111   pub slur_filter_regex: Option<Option<String>>,
112   pub actor_name_max_length: Option<i32>,
113   pub federation_enabled: Option<bool>,
114   pub captcha_enabled: Option<bool>,
115   pub captcha_difficulty: Option<String>,
116   pub registration_mode: Option<RegistrationMode>,
117   pub reports_email_admins: Option<bool>,
118   pub updated: Option<Option<chrono::NaiveDateTime>>,
119 }