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