]> Untitled Git - lemmy.git/blob - crates/db_schema/src/source/site.rs
b43783669af3f0c454b66c49ed3be8293c7c95be
[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, Debug, Clone, Serialize, Deserialize)]
8 #[cfg_attr(feature = "full", derive(Queryable, Identifiable))]
9 #[cfg_attr(feature = "full", 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 }
35
36 #[derive(Default)]
37 #[cfg_attr(feature = "full", derive(Insertable, AsChangeset))]
38 #[cfg_attr(feature = "full", table_name = "site")]
39 pub struct SiteForm {
40   pub name: String,
41   pub sidebar: Option<Option<String>>,
42   pub updated: Option<chrono::NaiveDateTime>,
43   pub enable_downvotes: Option<bool>,
44   pub open_registration: Option<bool>,
45   pub enable_nsfw: Option<bool>,
46   // 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.
47   pub icon: Option<Option<DbUrl>>,
48   pub banner: Option<Option<DbUrl>>,
49   pub description: Option<Option<String>>,
50   pub community_creation_admin_only: Option<bool>,
51   pub require_email_verification: Option<bool>,
52   pub require_application: Option<bool>,
53   pub application_question: Option<Option<String>>,
54   pub private_instance: Option<bool>,
55   pub actor_id: Option<DbUrl>,
56   pub last_refreshed_at: Option<chrono::NaiveDateTime>,
57   pub inbox_url: Option<DbUrl>,
58   pub private_key: Option<Option<String>>,
59   pub public_key: Option<String>,
60   pub default_theme: Option<String>,
61   pub default_post_listing_type: Option<String>,
62 }