]> Untitled Git - lemmy.git/blob - crates/db_schema/src/source/moderator.rs
Merge pull request #1850 from LemmyNet/refactor-apub
[lemmy.git] / crates / db_schema / src / source / moderator.rs
1 use crate::{
2   newtypes::{CommentId, CommunityId, PersonId, PostId},
3   schema::{
4     mod_add,
5     mod_add_community,
6     mod_ban,
7     mod_ban_from_community,
8     mod_lock_post,
9     mod_remove_comment,
10     mod_remove_community,
11     mod_remove_post,
12     mod_sticky_post,
13     mod_transfer_community,
14   },
15 };
16 use serde::{Deserialize, Serialize};
17
18 #[derive(Clone, Queryable, Identifiable, PartialEq, Debug, Serialize, Deserialize)]
19 #[table_name = "mod_remove_post"]
20 pub struct ModRemovePost {
21   pub id: i32,
22   pub mod_person_id: PersonId,
23   pub post_id: PostId,
24   pub reason: Option<String>,
25   pub removed: Option<bool>,
26   pub when_: chrono::NaiveDateTime,
27 }
28
29 #[derive(Insertable, AsChangeset)]
30 #[table_name = "mod_remove_post"]
31 pub struct ModRemovePostForm {
32   pub mod_person_id: PersonId,
33   pub post_id: PostId,
34   pub reason: Option<String>,
35   pub removed: Option<bool>,
36 }
37
38 #[derive(Clone, Queryable, Identifiable, PartialEq, Debug, Serialize, Deserialize)]
39 #[table_name = "mod_lock_post"]
40 pub struct ModLockPost {
41   pub id: i32,
42   pub mod_person_id: PersonId,
43   pub post_id: PostId,
44   pub locked: Option<bool>,
45   pub when_: chrono::NaiveDateTime,
46 }
47
48 #[derive(Insertable, AsChangeset)]
49 #[table_name = "mod_lock_post"]
50 pub struct ModLockPostForm {
51   pub mod_person_id: PersonId,
52   pub post_id: PostId,
53   pub locked: Option<bool>,
54 }
55
56 #[derive(Clone, Queryable, Identifiable, PartialEq, Debug, Serialize, Deserialize)]
57 #[table_name = "mod_sticky_post"]
58 pub struct ModStickyPost {
59   pub id: i32,
60   pub mod_person_id: PersonId,
61   pub post_id: PostId,
62   pub stickied: Option<bool>,
63   pub when_: chrono::NaiveDateTime,
64 }
65
66 #[derive(Insertable, AsChangeset)]
67 #[table_name = "mod_sticky_post"]
68 pub struct ModStickyPostForm {
69   pub mod_person_id: PersonId,
70   pub post_id: PostId,
71   pub stickied: Option<bool>,
72 }
73
74 #[derive(Clone, Queryable, Identifiable, PartialEq, Debug, Serialize, Deserialize)]
75 #[table_name = "mod_remove_comment"]
76 pub struct ModRemoveComment {
77   pub id: i32,
78   pub mod_person_id: PersonId,
79   pub comment_id: CommentId,
80   pub reason: Option<String>,
81   pub removed: Option<bool>,
82   pub when_: chrono::NaiveDateTime,
83 }
84
85 #[derive(Insertable, AsChangeset)]
86 #[table_name = "mod_remove_comment"]
87 pub struct ModRemoveCommentForm {
88   pub mod_person_id: PersonId,
89   pub comment_id: CommentId,
90   pub reason: Option<String>,
91   pub removed: Option<bool>,
92 }
93
94 #[derive(Clone, Queryable, Identifiable, PartialEq, Debug, Serialize, Deserialize)]
95 #[table_name = "mod_remove_community"]
96 pub struct ModRemoveCommunity {
97   pub id: i32,
98   pub mod_person_id: PersonId,
99   pub community_id: CommunityId,
100   pub reason: Option<String>,
101   pub removed: Option<bool>,
102   pub expires: Option<chrono::NaiveDateTime>,
103   pub when_: chrono::NaiveDateTime,
104 }
105
106 #[derive(Insertable, AsChangeset)]
107 #[table_name = "mod_remove_community"]
108 pub struct ModRemoveCommunityForm {
109   pub mod_person_id: PersonId,
110   pub community_id: CommunityId,
111   pub reason: Option<String>,
112   pub removed: Option<bool>,
113   pub expires: Option<chrono::NaiveDateTime>,
114 }
115
116 #[derive(Clone, Queryable, Identifiable, PartialEq, Debug, Serialize, Deserialize)]
117 #[table_name = "mod_ban_from_community"]
118 pub struct ModBanFromCommunity {
119   pub id: i32,
120   pub mod_person_id: PersonId,
121   pub other_person_id: PersonId,
122   pub community_id: CommunityId,
123   pub reason: Option<String>,
124   pub banned: Option<bool>,
125   pub expires: Option<chrono::NaiveDateTime>,
126   pub when_: chrono::NaiveDateTime,
127 }
128
129 #[derive(Insertable, AsChangeset)]
130 #[table_name = "mod_ban_from_community"]
131 pub struct ModBanFromCommunityForm {
132   pub mod_person_id: PersonId,
133   pub other_person_id: PersonId,
134   pub community_id: CommunityId,
135   pub reason: Option<String>,
136   pub banned: Option<bool>,
137   pub expires: Option<chrono::NaiveDateTime>,
138 }
139
140 #[derive(Clone, Queryable, Identifiable, PartialEq, Debug, Serialize, Deserialize)]
141 #[table_name = "mod_ban"]
142 pub struct ModBan {
143   pub id: i32,
144   pub mod_person_id: PersonId,
145   pub other_person_id: PersonId,
146   pub reason: Option<String>,
147   pub banned: Option<bool>,
148   pub expires: Option<chrono::NaiveDateTime>,
149   pub when_: chrono::NaiveDateTime,
150 }
151
152 #[derive(Insertable, AsChangeset)]
153 #[table_name = "mod_ban"]
154 pub struct ModBanForm {
155   pub mod_person_id: PersonId,
156   pub other_person_id: PersonId,
157   pub reason: Option<String>,
158   pub banned: Option<bool>,
159   pub expires: Option<chrono::NaiveDateTime>,
160 }
161
162 #[derive(Clone, Queryable, Identifiable, PartialEq, Debug, Serialize, Deserialize)]
163 #[table_name = "mod_add_community"]
164 pub struct ModAddCommunity {
165   pub id: i32,
166   pub mod_person_id: PersonId,
167   pub other_person_id: PersonId,
168   pub community_id: CommunityId,
169   pub removed: Option<bool>,
170   pub when_: chrono::NaiveDateTime,
171 }
172
173 #[derive(Insertable, AsChangeset)]
174 #[table_name = "mod_add_community"]
175 pub struct ModAddCommunityForm {
176   pub mod_person_id: PersonId,
177   pub other_person_id: PersonId,
178   pub community_id: CommunityId,
179   pub removed: Option<bool>,
180 }
181
182 #[derive(Clone, Queryable, Identifiable, PartialEq, Debug, Serialize, Deserialize)]
183 #[table_name = "mod_transfer_community"]
184 pub struct ModTransferCommunity {
185   pub id: i32,
186   pub mod_person_id: PersonId,
187   pub other_person_id: PersonId,
188   pub community_id: CommunityId,
189   pub removed: Option<bool>,
190   pub when_: chrono::NaiveDateTime,
191 }
192
193 #[derive(Insertable, AsChangeset)]
194 #[table_name = "mod_transfer_community"]
195 pub struct ModTransferCommunityForm {
196   pub mod_person_id: PersonId,
197   pub other_person_id: PersonId,
198   pub community_id: CommunityId,
199   pub removed: Option<bool>,
200 }
201
202 #[derive(Clone, Queryable, Identifiable, PartialEq, Debug, Serialize, Deserialize)]
203 #[table_name = "mod_add"]
204 pub struct ModAdd {
205   pub id: i32,
206   pub mod_person_id: PersonId,
207   pub other_person_id: PersonId,
208   pub removed: Option<bool>,
209   pub when_: chrono::NaiveDateTime,
210 }
211
212 #[derive(Insertable, AsChangeset)]
213 #[table_name = "mod_add"]
214 pub struct ModAddForm {
215   pub mod_person_id: PersonId,
216   pub other_person_id: PersonId,
217   pub removed: Option<bool>,
218 }