]> Untitled Git - lemmy.git/blob - crates/db_schema/src/source/community.rs
Dropping default on pending column.
[lemmy.git] / crates / db_schema / src / source / community.rs
1 use crate::newtypes::{CommunityId, DbUrl, PersonId};
2 use serde::{Deserialize, Serialize};
3
4 #[cfg(feature = "full")]
5 use crate::schema::{community, community_follower, community_moderator, community_person_ban};
6
7 #[derive(Clone, PartialEq, Debug, Serialize, Deserialize)]
8 #[cfg_attr(feature = "full", derive(Queryable, Identifiable))]
9 #[cfg_attr(feature = "full", table_name = "community")]
10 pub struct Community {
11   pub id: CommunityId,
12   pub name: String,
13   pub title: String,
14   pub description: Option<String>,
15   pub removed: bool,
16   pub published: chrono::NaiveDateTime,
17   pub updated: Option<chrono::NaiveDateTime>,
18   pub deleted: bool,
19   pub nsfw: bool,
20   pub actor_id: DbUrl,
21   pub local: bool,
22   pub private_key: Option<String>,
23   pub public_key: String,
24   pub last_refreshed_at: chrono::NaiveDateTime,
25   pub icon: Option<DbUrl>,
26   pub banner: Option<DbUrl>,
27   pub followers_url: DbUrl,
28   pub inbox_url: DbUrl,
29   pub shared_inbox_url: Option<DbUrl>,
30   pub hidden: bool,
31   pub posting_restricted_to_mods: bool,
32 }
33
34 /// A safe representation of community, without the sensitive info
35 #[derive(Clone, PartialEq, Debug, Serialize, Deserialize)]
36 #[cfg_attr(feature = "full", derive(Queryable, Identifiable))]
37 #[cfg_attr(feature = "full", table_name = "community")]
38 pub struct CommunitySafe {
39   pub id: CommunityId,
40   pub name: String,
41   pub title: String,
42   pub description: Option<String>,
43   pub removed: bool,
44   pub published: chrono::NaiveDateTime,
45   pub updated: Option<chrono::NaiveDateTime>,
46   pub deleted: bool,
47   pub nsfw: bool,
48   pub actor_id: DbUrl,
49   pub local: bool,
50   pub icon: Option<DbUrl>,
51   pub banner: Option<DbUrl>,
52   pub hidden: bool,
53   pub posting_restricted_to_mods: bool,
54 }
55
56 #[derive(Debug, Default)]
57 #[cfg_attr(feature = "full", derive(Insertable, AsChangeset))]
58 #[cfg_attr(feature = "full", table_name = "community")]
59 pub struct CommunityForm {
60   pub name: String,
61   pub title: String,
62   pub description: Option<String>,
63   pub removed: Option<bool>,
64   pub published: Option<chrono::NaiveDateTime>,
65   pub updated: Option<chrono::NaiveDateTime>,
66   pub deleted: Option<bool>,
67   pub nsfw: Option<bool>,
68   pub actor_id: Option<DbUrl>,
69   pub local: Option<bool>,
70   pub private_key: Option<Option<String>>,
71   pub public_key: String,
72   pub last_refreshed_at: Option<chrono::NaiveDateTime>,
73   pub icon: Option<Option<DbUrl>>,
74   pub banner: Option<Option<DbUrl>>,
75   pub followers_url: Option<DbUrl>,
76   pub inbox_url: Option<DbUrl>,
77   pub shared_inbox_url: Option<Option<DbUrl>>,
78   pub hidden: Option<bool>,
79   pub posting_restricted_to_mods: Option<bool>,
80 }
81
82 #[derive(PartialEq, Debug)]
83 #[cfg_attr(feature = "full", derive(Identifiable, Queryable, Associations))]
84 #[cfg_attr(feature = "full", belongs_to(Community))]
85 #[cfg_attr(feature = "full", table_name = "community_moderator")]
86 pub struct CommunityModerator {
87   pub id: i32,
88   pub community_id: CommunityId,
89   pub person_id: PersonId,
90   pub published: chrono::NaiveDateTime,
91 }
92
93 #[derive(Clone)]
94 #[cfg_attr(feature = "full", derive(Insertable, AsChangeset))]
95 #[cfg_attr(feature = "full", table_name = "community_moderator")]
96 pub struct CommunityModeratorForm {
97   pub community_id: CommunityId,
98   pub person_id: PersonId,
99 }
100
101 #[derive(PartialEq, Debug)]
102 #[cfg_attr(feature = "full", derive(Identifiable, Queryable, Associations))]
103 #[cfg_attr(feature = "full", belongs_to(Community))]
104 #[cfg_attr(feature = "full", table_name = "community_person_ban")]
105 pub struct CommunityPersonBan {
106   pub id: i32,
107   pub community_id: CommunityId,
108   pub person_id: PersonId,
109   pub published: chrono::NaiveDateTime,
110   pub expires: Option<chrono::NaiveDateTime>,
111 }
112
113 #[derive(Clone)]
114 #[cfg_attr(feature = "full", derive(Insertable, AsChangeset))]
115 #[cfg_attr(feature = "full", table_name = "community_person_ban")]
116 pub struct CommunityPersonBanForm {
117   pub community_id: CommunityId,
118   pub person_id: PersonId,
119   pub expires: Option<Option<chrono::NaiveDateTime>>,
120 }
121
122 #[derive(PartialEq, Debug)]
123 #[cfg_attr(feature = "full", derive(Identifiable, Queryable, Associations))]
124 #[cfg_attr(feature = "full", belongs_to(Community))]
125 #[cfg_attr(feature = "full", table_name = "community_follower")]
126 pub struct CommunityFollower {
127   pub id: i32,
128   pub community_id: CommunityId,
129   pub person_id: PersonId,
130   pub published: chrono::NaiveDateTime,
131   pub pending: bool,
132 }
133
134 #[derive(Clone)]
135 #[cfg_attr(feature = "full", derive(Insertable, AsChangeset))]
136 #[cfg_attr(feature = "full", table_name = "community_follower")]
137 pub struct CommunityFollowerForm {
138   pub community_id: CommunityId,
139   pub person_id: PersonId,
140   pub pending: bool,
141 }