]> Untitled Git - lemmy.git/blob - lemmy_structs/src/user.rs
Some API cleanup, adding site_id to site aggregates.
[lemmy.git] / lemmy_structs / src / user.rs
1 use lemmy_db::views::{
2   comment_view::CommentView,
3   community::{
4     community_follower_view::CommunityFollowerView,
5     community_moderator_view::CommunityModeratorView,
6   },
7   post_view::PostView,
8   private_message_view::PrivateMessageView,
9   user_mention_view::UserMentionView,
10   user_view::{UserViewDangerous, UserViewSafe},
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
20 #[derive(Deserialize)]
21 pub struct Register {
22   pub username: String,
23   pub email: Option<String>,
24   pub password: String,
25   pub password_verify: String,
26   pub admin: bool,
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>,
38 }
39
40 #[derive(Serialize)]
41 pub struct CaptchaResponse {
42   pub png: String,         // A Base64 encoded png
43   pub wav: Option<String>, // A Base64 encoded wav audio
44   pub uuid: String,
45 }
46
47 #[derive(Deserialize)]
48 pub struct SaveUserSettings {
49   pub show_nsfw: bool,
50   pub theme: String,
51   pub default_sort_type: String,
52   pub default_listing_type: String,
53   pub lang: String,
54   pub avatar: Option<String>,
55   pub banner: Option<String>,
56   pub preferred_username: Option<String>,
57   pub email: Option<String>,
58   pub bio: Option<String>,
59   pub matrix_user_id: Option<String>,
60   pub new_password: Option<String>,
61   pub new_password_verify: Option<String>,
62   pub old_password: Option<String>,
63   pub show_avatars: bool,
64   pub send_notifications_to_email: bool,
65   pub auth: String,
66 }
67
68 #[derive(Serialize)]
69 pub struct LoginResponse {
70   pub jwt: String,
71 }
72
73 #[derive(Deserialize)]
74 pub struct GetUserDetails {
75   pub user_id: Option<i32>,
76   pub username: Option<String>,
77   pub sort: String,
78   pub page: Option<i64>,
79   pub limit: Option<i64>,
80   pub community_id: Option<i32>,
81   pub saved_only: bool,
82   pub auth: Option<String>,
83 }
84
85 #[derive(Serialize)]
86 pub struct GetUserDetailsResponse {
87   pub user_view: Option<UserViewSafe>,
88   pub user_view_dangerous: Option<UserViewDangerous>,
89   pub follows: Vec<CommunityFollowerView>,
90   pub moderates: Vec<CommunityModeratorView>,
91   pub comments: Vec<CommentView>,
92   pub posts: Vec<PostView>,
93 }
94
95 #[derive(Serialize)]
96 pub struct GetRepliesResponse {
97   pub replies: Vec<CommentView>,
98 }
99
100 #[derive(Serialize)]
101 pub struct GetUserMentionsResponse {
102   pub mentions: Vec<UserMentionView>,
103 }
104
105 #[derive(Deserialize)]
106 pub struct MarkAllAsRead {
107   pub auth: String,
108 }
109
110 #[derive(Deserialize)]
111 pub struct AddAdmin {
112   pub user_id: i32,
113   pub added: bool,
114   pub auth: String,
115 }
116
117 #[derive(Serialize, Clone)]
118 pub struct AddAdminResponse {
119   pub admins: Vec<UserViewSafe>,
120 }
121
122 #[derive(Deserialize)]
123 pub struct BanUser {
124   pub user_id: i32,
125   pub ban: bool,
126   pub remove_data: bool,
127   pub reason: Option<String>,
128   pub expires: Option<i64>,
129   pub auth: String,
130 }
131
132 #[derive(Serialize, Clone)]
133 pub struct BanUserResponse {
134   pub user_view: UserViewSafe,
135   pub banned: bool,
136 }
137
138 #[derive(Deserialize)]
139 pub struct GetReplies {
140   pub sort: String,
141   pub page: Option<i64>,
142   pub limit: Option<i64>,
143   pub unread_only: bool,
144   pub auth: String,
145 }
146
147 #[derive(Deserialize)]
148 pub struct GetUserMentions {
149   pub sort: String,
150   pub page: Option<i64>,
151   pub limit: Option<i64>,
152   pub unread_only: bool,
153   pub auth: String,
154 }
155
156 #[derive(Deserialize)]
157 pub struct MarkUserMentionAsRead {
158   pub user_mention_id: i32,
159   pub read: bool,
160   pub auth: String,
161 }
162
163 #[derive(Serialize, Clone)]
164 pub struct UserMentionResponse {
165   pub user_mention_view: UserMentionView,
166 }
167
168 #[derive(Deserialize)]
169 pub struct DeleteAccount {
170   pub password: String,
171   pub auth: String,
172 }
173
174 #[derive(Deserialize)]
175 pub struct PasswordReset {
176   pub email: String,
177 }
178
179 #[derive(Serialize, Clone)]
180 pub struct PasswordResetResponse {}
181
182 #[derive(Deserialize)]
183 pub struct PasswordChange {
184   pub token: String,
185   pub password: String,
186   pub password_verify: String,
187 }
188
189 #[derive(Deserialize)]
190 pub struct CreatePrivateMessage {
191   pub content: String,
192   pub recipient_id: i32,
193   pub auth: String,
194 }
195
196 #[derive(Deserialize)]
197 pub struct EditPrivateMessage {
198   pub edit_id: i32,
199   pub content: String,
200   pub auth: String,
201 }
202
203 #[derive(Deserialize)]
204 pub struct DeletePrivateMessage {
205   pub edit_id: i32,
206   pub deleted: bool,
207   pub auth: String,
208 }
209
210 #[derive(Deserialize)]
211 pub struct MarkPrivateMessageAsRead {
212   pub edit_id: i32,
213   pub read: bool,
214   pub auth: String,
215 }
216
217 #[derive(Deserialize)]
218 pub struct GetPrivateMessages {
219   pub unread_only: bool,
220   pub page: Option<i64>,
221   pub limit: Option<i64>,
222   pub auth: String,
223 }
224
225 #[derive(Serialize, Clone)]
226 pub struct PrivateMessagesResponse {
227   pub private_messages: Vec<PrivateMessageView>,
228 }
229
230 #[derive(Serialize, Clone)]
231 pub struct PrivateMessageResponse {
232   pub private_message_view: PrivateMessageView,
233 }
234
235 #[derive(Deserialize, Debug)]
236 pub struct UserJoin {
237   pub auth: String,
238 }
239
240 #[derive(Serialize, Clone)]
241 pub struct UserJoinResponse {
242   pub joined: bool,
243 }
244
245 #[derive(Serialize, Deserialize, Debug)]
246 pub struct GetReportCount {
247   pub community: Option<i32>,
248   pub auth: String,
249 }
250
251 #[derive(Serialize, Deserialize, Clone, Debug)]
252 pub struct GetReportCountResponse {
253   pub community: Option<i32>,
254   pub comment_reports: i64,
255   pub post_reports: i64,
256 }