]> Untitled Git - lemmy.git/blob - server/lemmy_api_structs/src/user.rs
routes.api: fix get_captcha endpoint (#1135)
[lemmy.git] / server / lemmy_api_structs / src / user.rs
1 use lemmy_db::{
2   comment_view::{CommentView, ReplyView},
3   community_view::{CommunityFollowerView, CommunityModeratorView},
4   post_view::PostView,
5   private_message_view::PrivateMessageView,
6   user_mention_view::UserMentionView,
7   user_view::UserView,
8 };
9 use serde::{Deserialize, Serialize};
10
11 #[derive(Deserialize, Debug)]
12 pub struct Login {
13   pub username_or_email: String,
14   pub password: String,
15 }
16
17 #[derive(Deserialize)]
18 pub struct Register {
19   pub username: String,
20   pub email: Option<String>,
21   pub password: String,
22   pub password_verify: String,
23   pub admin: bool,
24   pub show_nsfw: bool,
25   pub captcha_uuid: Option<String>,
26   pub captcha_answer: Option<String>,
27 }
28
29 #[derive(Deserialize)]
30 pub struct GetCaptcha {}
31
32 #[derive(Serialize)]
33 pub struct GetCaptchaResponse {
34   pub ok: Option<CaptchaResponse>,
35 }
36
37 #[derive(Serialize)]
38 pub struct CaptchaResponse {
39   pub png: String,         // A Base64 encoded png
40   pub wav: Option<String>, // A Base64 encoded wav audio
41   pub uuid: String,
42 }
43
44 #[derive(Deserialize)]
45 pub struct SaveUserSettings {
46   pub show_nsfw: bool,
47   pub theme: String,
48   pub default_sort_type: i16,
49   pub default_listing_type: i16,
50   pub lang: String,
51   pub avatar: Option<String>,
52   pub banner: Option<String>,
53   pub preferred_username: Option<String>,
54   pub email: Option<String>,
55   pub bio: Option<String>,
56   pub matrix_user_id: Option<String>,
57   pub new_password: Option<String>,
58   pub new_password_verify: Option<String>,
59   pub old_password: Option<String>,
60   pub show_avatars: bool,
61   pub send_notifications_to_email: bool,
62   pub auth: String,
63 }
64
65 #[derive(Serialize)]
66 pub struct LoginResponse {
67   pub jwt: String,
68 }
69
70 #[derive(Deserialize)]
71 pub struct GetUserDetails {
72   pub user_id: Option<i32>,
73   pub username: Option<String>,
74   pub sort: String,
75   pub page: Option<i64>,
76   pub limit: Option<i64>,
77   pub community_id: Option<i32>,
78   pub saved_only: bool,
79   pub auth: Option<String>,
80 }
81
82 #[derive(Serialize)]
83 pub struct GetUserDetailsResponse {
84   pub user: UserView,
85   pub follows: Vec<CommunityFollowerView>,
86   pub moderates: Vec<CommunityModeratorView>,
87   pub comments: Vec<CommentView>,
88   pub posts: Vec<PostView>,
89 }
90
91 #[derive(Serialize)]
92 pub struct GetRepliesResponse {
93   pub replies: Vec<ReplyView>,
94 }
95
96 #[derive(Serialize)]
97 pub struct GetUserMentionsResponse {
98   pub mentions: Vec<UserMentionView>,
99 }
100
101 #[derive(Deserialize)]
102 pub struct MarkAllAsRead {
103   pub auth: String,
104 }
105
106 #[derive(Deserialize)]
107 pub struct AddAdmin {
108   pub user_id: i32,
109   pub added: bool,
110   pub auth: String,
111 }
112
113 #[derive(Serialize, Clone)]
114 pub struct AddAdminResponse {
115   pub admins: Vec<UserView>,
116 }
117
118 #[derive(Deserialize)]
119 pub struct BanUser {
120   pub user_id: i32,
121   pub ban: bool,
122   pub remove_data: Option<bool>,
123   pub reason: Option<String>,
124   pub expires: Option<i64>,
125   pub auth: String,
126 }
127
128 #[derive(Serialize, Clone)]
129 pub struct BanUserResponse {
130   pub user: UserView,
131   pub banned: bool,
132 }
133
134 #[derive(Deserialize)]
135 pub struct GetReplies {
136   pub sort: String,
137   pub page: Option<i64>,
138   pub limit: Option<i64>,
139   pub unread_only: bool,
140   pub auth: String,
141 }
142
143 #[derive(Deserialize)]
144 pub struct GetUserMentions {
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 MarkUserMentionAsRead {
154   pub user_mention_id: i32,
155   pub read: bool,
156   pub auth: String,
157 }
158
159 #[derive(Serialize, Clone)]
160 pub struct UserMentionResponse {
161   pub mention: UserMentionView,
162 }
163
164 #[derive(Deserialize)]
165 pub struct DeleteAccount {
166   pub password: String,
167   pub auth: String,
168 }
169
170 #[derive(Deserialize)]
171 pub struct PasswordReset {
172   pub email: String,
173 }
174
175 #[derive(Serialize, Clone)]
176 pub struct PasswordResetResponse {}
177
178 #[derive(Deserialize)]
179 pub struct PasswordChange {
180   pub token: String,
181   pub password: String,
182   pub password_verify: String,
183 }
184
185 #[derive(Deserialize)]
186 pub struct CreatePrivateMessage {
187   pub content: String,
188   pub recipient_id: i32,
189   pub auth: String,
190 }
191
192 #[derive(Deserialize)]
193 pub struct EditPrivateMessage {
194   pub edit_id: i32,
195   pub content: String,
196   pub auth: String,
197 }
198
199 #[derive(Deserialize)]
200 pub struct DeletePrivateMessage {
201   pub edit_id: i32,
202   pub deleted: bool,
203   pub auth: String,
204 }
205
206 #[derive(Deserialize)]
207 pub struct MarkPrivateMessageAsRead {
208   pub edit_id: i32,
209   pub read: bool,
210   pub auth: String,
211 }
212
213 #[derive(Deserialize)]
214 pub struct GetPrivateMessages {
215   pub unread_only: bool,
216   pub page: Option<i64>,
217   pub limit: Option<i64>,
218   pub auth: String,
219 }
220
221 #[derive(Serialize, Clone)]
222 pub struct PrivateMessagesResponse {
223   pub messages: Vec<PrivateMessageView>,
224 }
225
226 #[derive(Serialize, Clone)]
227 pub struct PrivateMessageResponse {
228   pub message: PrivateMessageView,
229 }
230
231 #[derive(Deserialize, Debug)]
232 pub struct UserJoin {
233   pub auth: String,
234 }
235
236 #[derive(Serialize, Clone)]
237 pub struct UserJoinResponse {
238   pub user_id: i32,
239 }