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