]> Untitled Git - lemmy.git/blob - crates/db_schema/src/source/site.rs
82876d837200aa229e7e75384357f54259ab46c0
[lemmy.git] / crates / db_schema / src / source / site.rs
1 use crate::newtypes::DbUrl;
2 use serde::{Deserialize, Serialize};
3
4 #[cfg(feature = "full")]
5 use crate::schema::site;
6
7 #[derive(PartialEq, Eq, Debug, Clone, Serialize, Deserialize)]
8 #[cfg_attr(feature = "full", derive(Queryable, Identifiable))]
9 #[cfg_attr(feature = "full", diesel(table_name = site))]
10 pub struct Site {
11   pub id: i32,
12   pub name: String,
13   pub sidebar: Option<String>,
14   pub published: chrono::NaiveDateTime,
15   pub updated: Option<chrono::NaiveDateTime>,
16   pub enable_downvotes: bool,
17   pub open_registration: bool,
18   pub enable_nsfw: bool,
19   pub icon: Option<DbUrl>,
20   pub banner: Option<DbUrl>,
21   pub description: Option<String>,
22   pub community_creation_admin_only: bool,
23   pub require_email_verification: bool,
24   pub require_application: bool,
25   pub application_question: Option<String>,
26   pub private_instance: bool,
27   pub actor_id: DbUrl,
28   pub last_refreshed_at: chrono::NaiveDateTime,
29   pub inbox_url: DbUrl,
30   pub private_key: Option<String>,
31   pub public_key: String,
32   pub default_theme: String,
33   pub default_post_listing_type: String,
34   pub legal_information: Option<String>,
35   pub hide_modlog_mod_names: bool,
36 }
37
38 #[derive(Default)]
39 #[cfg_attr(feature = "full", derive(Insertable, AsChangeset))]
40 #[cfg_attr(feature = "full", diesel(table_name = site))]
41 pub struct SiteForm {
42   pub name: String,
43   pub sidebar: Option<Option<String>>,
44   pub updated: Option<chrono::NaiveDateTime>,
45   pub enable_downvotes: Option<bool>,
46   pub open_registration: Option<bool>,
47   pub enable_nsfw: Option<bool>,
48   // when you want to null out a column, you have to send Some(None)), since sending None means you just don't want to update that column.
49   pub icon: Option<Option<DbUrl>>,
50   pub banner: Option<Option<DbUrl>>,
51   pub description: Option<Option<String>>,
52   pub community_creation_admin_only: Option<bool>,
53   pub require_email_verification: Option<bool>,
54   pub require_application: Option<bool>,
55   pub application_question: Option<Option<String>>,
56   pub private_instance: Option<bool>,
57   pub actor_id: Option<DbUrl>,
58   pub last_refreshed_at: Option<chrono::NaiveDateTime>,
59   pub inbox_url: Option<DbUrl>,
60   pub private_key: Option<Option<String>>,
61   pub public_key: Option<String>,
62   pub default_theme: Option<String>,
63   pub default_post_listing_type: Option<String>,
64   pub legal_information: Option<Option<String>>,
65   pub hide_modlog_mod_names: Option<bool>,
66 }