]> Untitled Git - lemmy.git/blob - crates/api_common/src/person.rs
Merge pull request #1564 from LemmyNet/remove_extra_save_user_fields
[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_follower_view::CommunityFollowerView,
8   community_moderator_view::CommunityModeratorView,
9   person_mention_view::PersonMentionView,
10   person_view::PersonViewSafe,
11 };
12 use serde::{Deserialize, Serialize};
13
14 #[derive(Deserialize, Debug)]
15 pub struct Login {
16   pub username_or_email: String,
17   pub password: String,
18 }
19 use lemmy_db_schema::{CommunityId, PersonId, PersonMentionId, PrivateMessageId};
20
21 #[derive(Deserialize)]
22 pub struct Register {
23   pub username: String,
24   pub email: Option<String>,
25   pub password: String,
26   pub password_verify: String,
27   pub show_nsfw: bool,
28   pub captcha_uuid: Option<String>,
29   pub captcha_answer: 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 auth: String,
64 }
65
66 #[derive(Deserialize)]
67 pub struct ChangePassword {
68   pub new_password: String,
69   pub new_password_verify: String,
70   pub old_password: String,
71   pub auth: String,
72 }
73
74 #[derive(Serialize)]
75 pub struct LoginResponse {
76   pub jwt: String,
77 }
78
79 #[derive(Deserialize)]
80 pub struct GetPersonDetails {
81   pub person_id: Option<PersonId>,
82   pub username: Option<String>,
83   pub sort: String,
84   pub page: Option<i64>,
85   pub limit: Option<i64>,
86   pub community_id: Option<CommunityId>,
87   pub saved_only: bool,
88   pub auth: Option<String>,
89 }
90
91 #[derive(Serialize)]
92 pub struct GetPersonDetailsResponse {
93   pub person_view: PersonViewSafe,
94   pub follows: Vec<CommunityFollowerView>,
95   pub moderates: Vec<CommunityModeratorView>,
96   pub comments: Vec<CommentView>,
97   pub posts: Vec<PostView>,
98 }
99
100 #[derive(Serialize)]
101 pub struct GetRepliesResponse {
102   pub replies: Vec<CommentView>,
103 }
104
105 #[derive(Serialize)]
106 pub struct GetPersonMentionsResponse {
107   pub mentions: Vec<PersonMentionView>,
108 }
109
110 #[derive(Deserialize)]
111 pub struct MarkAllAsRead {
112   pub auth: String,
113 }
114
115 #[derive(Deserialize)]
116 pub struct AddAdmin {
117   pub person_id: PersonId,
118   pub added: bool,
119   pub auth: String,
120 }
121
122 #[derive(Serialize, Clone)]
123 pub struct AddAdminResponse {
124   pub admins: Vec<PersonViewSafe>,
125 }
126
127 #[derive(Deserialize)]
128 pub struct BanPerson {
129   pub person_id: PersonId,
130   pub ban: bool,
131   pub remove_data: bool,
132   pub reason: Option<String>,
133   pub expires: Option<i64>,
134   pub auth: String,
135 }
136
137 #[derive(Serialize, Clone)]
138 pub struct BanPersonResponse {
139   pub person_view: PersonViewSafe,
140   pub banned: bool,
141 }
142
143 #[derive(Deserialize)]
144 pub struct GetReplies {
145   pub sort: String,
146   pub page: Option<i64>,
147   pub limit: Option<i64>,
148   pub unread_only: bool,
149   pub auth: String,
150 }
151
152 #[derive(Deserialize)]
153 pub struct GetPersonMentions {
154   pub sort: String,
155   pub page: Option<i64>,
156   pub limit: Option<i64>,
157   pub unread_only: bool,
158   pub auth: String,
159 }
160
161 #[derive(Deserialize)]
162 pub struct MarkPersonMentionAsRead {
163   pub person_mention_id: PersonMentionId,
164   pub read: bool,
165   pub auth: String,
166 }
167
168 #[derive(Serialize, Clone)]
169 pub struct PersonMentionResponse {
170   pub person_mention_view: PersonMentionView,
171 }
172
173 #[derive(Deserialize)]
174 pub struct DeleteAccount {
175   pub password: String,
176   pub auth: String,
177 }
178
179 #[derive(Deserialize)]
180 pub struct PasswordReset {
181   pub email: String,
182 }
183
184 #[derive(Serialize, Clone)]
185 pub struct PasswordResetResponse {}
186
187 #[derive(Deserialize)]
188 pub struct PasswordChange {
189   pub token: String,
190   pub password: String,
191   pub password_verify: String,
192 }
193
194 #[derive(Deserialize)]
195 pub struct CreatePrivateMessage {
196   pub content: String,
197   pub recipient_id: PersonId,
198   pub auth: String,
199 }
200
201 #[derive(Deserialize)]
202 pub struct EditPrivateMessage {
203   pub private_message_id: PrivateMessageId,
204   pub content: String,
205   pub auth: String,
206 }
207
208 #[derive(Deserialize)]
209 pub struct DeletePrivateMessage {
210   pub private_message_id: PrivateMessageId,
211   pub deleted: bool,
212   pub auth: String,
213 }
214
215 #[derive(Deserialize)]
216 pub struct MarkPrivateMessageAsRead {
217   pub private_message_id: PrivateMessageId,
218   pub read: bool,
219   pub auth: String,
220 }
221
222 #[derive(Deserialize)]
223 pub struct GetPrivateMessages {
224   pub unread_only: bool,
225   pub page: Option<i64>,
226   pub limit: Option<i64>,
227   pub auth: String,
228 }
229
230 #[derive(Serialize, Clone)]
231 pub struct PrivateMessagesResponse {
232   pub private_messages: Vec<PrivateMessageView>,
233 }
234
235 #[derive(Serialize, Clone)]
236 pub struct PrivateMessageResponse {
237   pub private_message_view: PrivateMessageView,
238 }
239
240 #[derive(Serialize, Deserialize, Debug)]
241 pub struct GetReportCount {
242   pub community: Option<CommunityId>,
243   pub auth: String,
244 }
245
246 #[derive(Serialize, Deserialize, Clone, Debug)]
247 pub struct GetReportCountResponse {
248   pub community: Option<CommunityId>,
249   pub comment_reports: i64,
250   pub post_reports: i64,
251 }