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