]> Untitled Git - lemmy.git/blob - crates/db_schema/src/source/site.rs
implement language tags for site/community in db and api (#2434)
[lemmy.git] / crates / db_schema / src / source / site.rs
1 use crate::newtypes::{DbUrl, SiteId};
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: SiteId,
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 application_email_admins: bool,
36   pub hide_modlog_mod_names: bool,
37 }
38
39 #[derive(Default)]
40 #[cfg_attr(feature = "full", derive(Insertable, AsChangeset))]
41 #[cfg_attr(feature = "full", diesel(table_name = site))]
42 pub struct SiteForm {
43   pub name: String,
44   pub sidebar: Option<Option<String>>,
45   pub updated: Option<chrono::NaiveDateTime>,
46   pub enable_downvotes: Option<bool>,
47   pub open_registration: Option<bool>,
48   pub enable_nsfw: Option<bool>,
49   // 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.
50   pub icon: Option<Option<DbUrl>>,
51   pub banner: Option<Option<DbUrl>>,
52   pub description: Option<Option<String>>,
53   pub community_creation_admin_only: Option<bool>,
54   pub require_email_verification: Option<bool>,
55   pub require_application: Option<bool>,
56   pub application_question: Option<Option<String>>,
57   pub private_instance: Option<bool>,
58   pub actor_id: Option<DbUrl>,
59   pub last_refreshed_at: Option<chrono::NaiveDateTime>,
60   pub inbox_url: Option<DbUrl>,
61   pub private_key: Option<Option<String>>,
62   pub public_key: Option<String>,
63   pub default_theme: Option<String>,
64   pub default_post_listing_type: Option<String>,
65   pub legal_information: Option<Option<String>>,
66   pub application_email_admins: Option<bool>,
67   pub hide_modlog_mod_names: Option<bool>,
68 }