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