]> Untitled Git - lemmy.git/blob - crates/api_common/src/person.rs
Allow filtering out of deleted and removed comments when getting person details ...
[lemmy.git] / crates / api_common / src / person.rs
1 use crate::sensitive::Sensitive;
2 use lemmy_db_schema::{
3   newtypes::{CommentReplyId, CommunityId, LanguageId, PersonId, PersonMentionId},
4   CommentSortType,
5   SortType,
6 };
7 use lemmy_db_views::structs::{CommentView, PostView};
8 use lemmy_db_views_actor::structs::{
9   CommentReplyView,
10   CommunityModeratorView,
11   PersonMentionView,
12   PersonViewSafe,
13 };
14 use serde::{Deserialize, Serialize};
15
16 #[derive(Debug, Serialize, Deserialize, Clone, Default)]
17 pub struct Login {
18   pub username_or_email: Sensitive<String>,
19   pub password: Sensitive<String>,
20 }
21
22 #[derive(Debug, Serialize, Deserialize, Clone, Default)]
23 pub struct Register {
24   pub username: String,
25   pub password: Sensitive<String>,
26   pub password_verify: Sensitive<String>,
27   pub show_nsfw: bool,
28   /// email is mandatory if email verification is enabled on the server
29   pub email: Option<Sensitive<String>>,
30   pub captcha_uuid: Option<String>,
31   pub captcha_answer: Option<String>,
32   pub honeypot: Option<String>,
33   /// An answer is mandatory if require application is enabled on the server
34   pub answer: Option<String>,
35 }
36
37 #[derive(Debug, Serialize, Deserialize, Clone, Default)]
38 pub struct GetCaptcha {}
39
40 #[derive(Debug, Serialize, Deserialize, Clone)]
41 pub struct GetCaptchaResponse {
42   pub ok: Option<CaptchaResponse>, // Will be None if captchas are disabled
43 }
44
45 #[derive(Debug, Serialize, Deserialize, Clone)]
46 pub struct CaptchaResponse {
47   pub png: String, // A Base64 encoded png
48   pub wav: String, // A Base64 encoded wav audio
49   pub uuid: String,
50 }
51
52 #[derive(Debug, Serialize, Deserialize, Clone, Default)]
53 pub struct SaveUserSettings {
54   pub show_nsfw: Option<bool>,
55   pub show_scores: Option<bool>,
56   pub theme: Option<String>,
57   pub default_sort_type: Option<i16>,
58   pub default_listing_type: Option<i16>,
59   pub interface_language: Option<String>,
60   pub avatar: Option<String>,
61   pub banner: Option<String>,
62   pub display_name: Option<String>,
63   pub email: Option<Sensitive<String>>,
64   pub bio: Option<String>,
65   pub matrix_user_id: Option<String>,
66   pub show_avatars: Option<bool>,
67   pub send_notifications_to_email: Option<bool>,
68   pub bot_account: Option<bool>,
69   pub show_bot_accounts: Option<bool>,
70   pub show_read_posts: Option<bool>,
71   pub show_new_post_notifs: Option<bool>,
72   pub discussion_languages: Option<Vec<LanguageId>>,
73   pub auth: Sensitive<String>,
74 }
75
76 #[derive(Debug, Serialize, Deserialize, Clone, Default)]
77 pub struct ChangePassword {
78   pub new_password: Sensitive<String>,
79   pub new_password_verify: Sensitive<String>,
80   pub old_password: Sensitive<String>,
81   pub auth: Sensitive<String>,
82 }
83
84 #[derive(Debug, Serialize, Deserialize, Clone)]
85 pub struct LoginResponse {
86   /// This is None in response to `Register` if email verification is enabled, or the server requires registration applications.
87   pub jwt: Option<Sensitive<String>>,
88   pub registration_created: bool,
89   pub verify_email_sent: bool,
90 }
91
92 #[derive(Debug, Serialize, Deserialize, Clone, Default)]
93 pub struct GetPersonDetails {
94   pub person_id: Option<PersonId>, // One of these two are required
95   /// Example: dessalines , or dessalines@xyz.tld
96   pub username: Option<String>,
97   pub sort: Option<SortType>,
98   pub page: Option<i64>,
99   pub limit: Option<i64>,
100   pub community_id: Option<CommunityId>,
101   pub saved_only: Option<bool>,
102   pub show_deleted_and_removed: Option<bool>,
103   pub auth: Option<Sensitive<String>>,
104 }
105
106 #[derive(Debug, Serialize, Deserialize, Clone)]
107 pub struct GetPersonDetailsResponse {
108   pub person_view: PersonViewSafe,
109   pub comments: Vec<CommentView>,
110   pub posts: Vec<PostView>,
111   pub moderates: Vec<CommunityModeratorView>,
112 }
113
114 #[derive(Debug, Serialize, Deserialize, Clone, Default)]
115 pub struct GetRepliesResponse {
116   pub replies: Vec<CommentReplyView>,
117 }
118
119 #[derive(Debug, Serialize, Deserialize, Clone)]
120 pub struct GetPersonMentionsResponse {
121   pub mentions: Vec<PersonMentionView>,
122 }
123
124 #[derive(Debug, Serialize, Deserialize, Clone, Default)]
125 pub struct MarkAllAsRead {
126   pub auth: Sensitive<String>,
127 }
128
129 #[derive(Debug, Serialize, Deserialize, Clone, Default)]
130 pub struct AddAdmin {
131   pub person_id: PersonId,
132   pub added: bool,
133   pub auth: Sensitive<String>,
134 }
135
136 #[derive(Debug, Serialize, Deserialize, Clone)]
137 pub struct AddAdminResponse {
138   pub admins: Vec<PersonViewSafe>,
139 }
140
141 #[derive(Debug, Serialize, Deserialize, Clone, Default)]
142 pub struct BanPerson {
143   pub person_id: PersonId,
144   pub ban: bool,
145   pub remove_data: Option<bool>,
146   pub reason: Option<String>,
147   pub expires: Option<i64>,
148   pub auth: Sensitive<String>,
149 }
150
151 #[derive(Debug, Serialize, Deserialize, Clone, Default)]
152 pub struct GetBannedPersons {
153   pub auth: String,
154 }
155
156 #[derive(Debug, Serialize, Deserialize, Clone)]
157 pub struct BannedPersonsResponse {
158   pub banned: Vec<PersonViewSafe>,
159 }
160
161 #[derive(Debug, Serialize, Deserialize, Clone)]
162 pub struct BanPersonResponse {
163   pub person_view: PersonViewSafe,
164   pub banned: bool,
165 }
166
167 #[derive(Debug, Serialize, Deserialize, Clone, Default)]
168 pub struct BlockPerson {
169   pub person_id: PersonId,
170   pub block: bool,
171   pub auth: Sensitive<String>,
172 }
173
174 #[derive(Debug, Serialize, Deserialize, Clone)]
175 pub struct BlockPersonResponse {
176   pub person_view: PersonViewSafe,
177   pub blocked: bool,
178 }
179
180 #[derive(Debug, Serialize, Deserialize, Clone, Default)]
181 pub struct GetReplies {
182   pub sort: Option<CommentSortType>,
183   pub page: Option<i64>,
184   pub limit: Option<i64>,
185   pub unread_only: Option<bool>,
186   pub auth: Sensitive<String>,
187 }
188
189 #[derive(Debug, Serialize, Deserialize, Clone, Default)]
190 pub struct GetPersonMentions {
191   pub sort: Option<CommentSortType>,
192   pub page: Option<i64>,
193   pub limit: Option<i64>,
194   pub unread_only: Option<bool>,
195   pub auth: Sensitive<String>,
196 }
197
198 #[derive(Debug, Serialize, Deserialize, Clone, Default)]
199 pub struct MarkPersonMentionAsRead {
200   pub person_mention_id: PersonMentionId,
201   pub read: bool,
202   pub auth: Sensitive<String>,
203 }
204
205 #[derive(Debug, Serialize, Deserialize, Clone)]
206 pub struct PersonMentionResponse {
207   pub person_mention_view: PersonMentionView,
208 }
209
210 #[derive(Debug, Serialize, Deserialize, Clone, Default)]
211 pub struct MarkCommentReplyAsRead {
212   pub comment_reply_id: CommentReplyId,
213   pub read: bool,
214   pub auth: Sensitive<String>,
215 }
216
217 #[derive(Debug, Serialize, Deserialize, Clone)]
218 pub struct CommentReplyResponse {
219   pub comment_reply_view: CommentReplyView,
220 }
221
222 #[derive(Debug, Serialize, Deserialize, Clone, Default)]
223 pub struct DeleteAccount {
224   pub password: Sensitive<String>,
225   pub auth: Sensitive<String>,
226 }
227
228 #[derive(Debug, Serialize, Deserialize, Clone)]
229 pub struct DeleteAccountResponse {}
230
231 #[derive(Debug, Serialize, Deserialize, Clone, Default)]
232 pub struct PasswordReset {
233   pub email: Sensitive<String>,
234 }
235
236 #[derive(Debug, Serialize, Deserialize, Clone)]
237 pub struct PasswordResetResponse {}
238
239 #[derive(Debug, Serialize, Deserialize, Clone, Default)]
240 pub struct PasswordChangeAfterReset {
241   pub token: Sensitive<String>,
242   pub password: Sensitive<String>,
243   pub password_verify: Sensitive<String>,
244 }
245
246 #[derive(Debug, Serialize, Deserialize, Clone, Default)]
247 pub struct GetReportCount {
248   pub community_id: Option<CommunityId>,
249   pub auth: Sensitive<String>,
250 }
251
252 #[derive(Debug, Serialize, Deserialize, Clone)]
253 pub struct GetReportCountResponse {
254   pub community_id: Option<CommunityId>,
255   pub comment_reports: i64,
256   pub post_reports: i64,
257   pub private_message_reports: Option<i64>,
258 }
259
260 #[derive(Debug, Serialize, Deserialize, Clone, Default)]
261 pub struct GetUnreadCount {
262   pub auth: Sensitive<String>,
263 }
264
265 #[derive(Debug, Serialize, Deserialize, Clone)]
266 pub struct GetUnreadCountResponse {
267   pub replies: i64,
268   pub mentions: i64,
269   pub private_messages: i64,
270 }
271
272 #[derive(Serialize, Deserialize, Clone, Default)]
273 pub struct VerifyEmail {
274   pub token: String,
275 }
276
277 #[derive(Debug, Serialize, Deserialize, Clone)]
278 pub struct VerifyEmailResponse {}