1 use crate::sensitive::Sensitive;
3 newtypes::{CommentReplyId, CommunityId, LanguageId, PersonId, PersonMentionId},
8 use lemmy_db_views::structs::{CommentView, PostView};
9 use lemmy_db_views_actor::structs::{
11 CommunityModeratorView,
15 use serde::{Deserialize, Serialize};
16 use serde_with::skip_serializing_none;
17 #[cfg(feature = "full")]
20 #[skip_serializing_none]
21 #[derive(Debug, Serialize, Deserialize, Clone, Default)]
22 #[cfg_attr(feature = "full", derive(TS))]
23 #[cfg_attr(feature = "full", ts(export))]
24 /// Logging into lemmy.
26 pub username_or_email: Sensitive<String>,
27 pub password: Sensitive<String>,
28 /// May be required, if totp is enabled for their account.
29 pub totp_2fa_token: Option<String>,
32 #[skip_serializing_none]
33 #[derive(Debug, Serialize, Deserialize, Clone, Default)]
34 #[cfg_attr(feature = "full", derive(TS))]
35 #[cfg_attr(feature = "full", ts(export))]
36 /// Register / Sign up to lemmy.
39 pub password: Sensitive<String>,
40 pub password_verify: Sensitive<String>,
42 /// email is mandatory if email verification is enabled on the server
43 pub email: Option<Sensitive<String>>,
44 /// The UUID of the captcha item.
45 pub captcha_uuid: Option<String>,
46 /// Your captcha answer.
47 pub captcha_answer: Option<String>,
48 /// A form field to trick signup bots. Should be None.
49 pub honeypot: Option<String>,
50 /// An answer is mandatory if require application is enabled on the server
51 pub answer: Option<String>,
54 #[skip_serializing_none]
55 #[derive(Debug, Serialize, Deserialize, Clone, Default)]
56 #[cfg_attr(feature = "full", derive(TS))]
57 #[cfg_attr(feature = "full", ts(export))]
58 /// Fetches a Captcha item.
59 pub struct GetCaptcha {
60 pub auth: Option<Sensitive<String>>,
63 #[skip_serializing_none]
64 #[derive(Debug, Serialize, Deserialize, Clone)]
65 #[cfg_attr(feature = "full", derive(TS))]
66 #[cfg_attr(feature = "full", ts(export))]
67 /// A wrapper for the captcha response.
68 pub struct GetCaptchaResponse {
69 /// Will be None if captchas are disabled.
70 pub ok: Option<CaptchaResponse>,
73 #[derive(Debug, Serialize, Deserialize, Clone)]
74 #[cfg_attr(feature = "full", derive(TS))]
75 #[cfg_attr(feature = "full", ts(export))]
76 /// A captcha response.
77 pub struct CaptchaResponse {
78 /// A Base64 encoded png
80 /// A Base64 encoded wav audio
82 /// The UUID for the captcha item.
86 #[skip_serializing_none]
87 #[derive(Debug, Serialize, Deserialize, Clone, Default)]
88 #[cfg_attr(feature = "full", derive(TS))]
89 #[cfg_attr(feature = "full", ts(export))]
90 /// Saves settings for your user.
91 pub struct SaveUserSettings {
93 pub show_nsfw: Option<bool>,
94 /// Show post and comment scores.
95 pub show_scores: Option<bool>,
96 /// Your user's theme.
97 pub theme: Option<String>,
98 pub default_sort_type: Option<SortType>,
99 pub default_listing_type: Option<ListingType>,
100 /// The language of the lemmy interface
101 pub interface_language: Option<String>,
102 /// A URL for your avatar.
103 pub avatar: Option<String>,
104 /// A URL for your banner.
105 pub banner: Option<String>,
106 /// Your display name, which can contain strange characters, and does not need to be unique.
107 pub display_name: Option<String>,
109 pub email: Option<Sensitive<String>>,
110 /// Your bio / info, in markdown.
111 pub bio: Option<String>,
112 /// Your matrix user id. Ex: @my_user:matrix.org
113 pub matrix_user_id: Option<String>,
114 /// Whether to show or hide avatars.
115 pub show_avatars: Option<bool>,
116 /// Sends notifications to your email.
117 pub send_notifications_to_email: Option<bool>,
118 /// Whether this account is a bot account. Users can hide these accounts easily if they wish.
119 pub bot_account: Option<bool>,
120 /// Whether to show bot accounts.
121 pub show_bot_accounts: Option<bool>,
122 /// Whether to show read posts.
123 pub show_read_posts: Option<bool>,
124 /// Whether to show notifications for new posts.
125 // TODO notifs need to be reworked.
126 pub show_new_post_notifs: Option<bool>,
127 /// A list of languages you are able to see discussion in.
128 pub discussion_languages: Option<Vec<LanguageId>>,
129 /// Generates a TOTP / 2-factor authentication token.
131 /// None leaves it as is, true will generate or regenerate it, false clears it out.
132 pub generate_totp_2fa: Option<bool>,
133 pub auth: Sensitive<String>,
136 #[derive(Debug, Serialize, Deserialize, Clone, Default)]
137 #[cfg_attr(feature = "full", derive(TS))]
138 #[cfg_attr(feature = "full", ts(export))]
139 /// Changes your account password.
140 pub struct ChangePassword {
141 pub new_password: Sensitive<String>,
142 pub new_password_verify: Sensitive<String>,
143 pub old_password: Sensitive<String>,
144 pub auth: Sensitive<String>,
147 #[skip_serializing_none]
148 #[derive(Debug, Serialize, Deserialize, Clone)]
149 #[cfg_attr(feature = "full", derive(TS))]
150 #[cfg_attr(feature = "full", ts(export))]
151 /// A response for your login.
152 pub struct LoginResponse {
153 /// This is None in response to `Register` if email verification is enabled, or the server requires registration applications.
154 pub jwt: Option<Sensitive<String>>,
155 /// If registration applications are required, this will return true for a signup response.
156 pub registration_created: bool,
157 /// If email verifications are required, this will return true for a signup response.
158 pub verify_email_sent: bool,
161 #[skip_serializing_none]
162 #[derive(Debug, Serialize, Deserialize, Clone, Default)]
163 #[cfg_attr(feature = "full", derive(TS))]
164 #[cfg_attr(feature = "full", ts(export))]
165 /// Gets a person's details.
167 /// Either person_id, or username are required.
168 pub struct GetPersonDetails {
169 pub person_id: Option<PersonId>,
170 /// Example: dessalines , or dessalines@xyz.tld
171 pub username: Option<String>,
172 pub sort: Option<SortType>,
173 pub page: Option<i64>,
174 pub limit: Option<i64>,
175 pub community_id: Option<CommunityId>,
176 pub saved_only: Option<bool>,
177 pub auth: Option<Sensitive<String>>,
180 #[derive(Debug, Serialize, Deserialize, Clone)]
181 #[cfg_attr(feature = "full", derive(TS))]
182 #[cfg_attr(feature = "full", ts(export))]
183 /// A person's details response.
184 pub struct GetPersonDetailsResponse {
185 pub person_view: PersonView,
186 pub comments: Vec<CommentView>,
187 pub posts: Vec<PostView>,
188 pub moderates: Vec<CommunityModeratorView>,
191 #[derive(Debug, Serialize, Deserialize, Clone, Default)]
192 #[cfg_attr(feature = "full", derive(TS))]
193 #[cfg_attr(feature = "full", ts(export))]
194 /// Marks all notifications as read.
195 pub struct MarkAllAsRead {
196 pub auth: Sensitive<String>,
199 #[derive(Debug, Serialize, Deserialize, Clone, Default)]
200 #[cfg_attr(feature = "full", derive(TS))]
201 #[cfg_attr(feature = "full", ts(export))]
202 /// Adds an admin to a site.
203 pub struct AddAdmin {
204 pub person_id: PersonId,
206 pub auth: Sensitive<String>,
209 #[derive(Debug, Serialize, Deserialize, Clone)]
210 #[cfg_attr(feature = "full", derive(TS))]
211 #[cfg_attr(feature = "full", ts(export))]
212 /// The response of current admins.
213 pub struct AddAdminResponse {
214 pub admins: Vec<PersonView>,
217 #[skip_serializing_none]
218 #[derive(Debug, Serialize, Deserialize, Clone, Default)]
219 #[cfg_attr(feature = "full", derive(TS))]
220 #[cfg_attr(feature = "full", ts(export))]
221 /// Ban a person from the site.
222 pub struct BanPerson {
223 pub person_id: PersonId,
225 /// Optionally remove all their data. Useful for new troll accounts.
226 pub remove_data: Option<bool>,
227 pub reason: Option<String>,
228 pub expires: Option<i64>,
229 pub auth: Sensitive<String>,
232 #[derive(Debug, Serialize, Deserialize, Clone, Default)]
233 #[cfg_attr(feature = "full", derive(TS))]
234 #[cfg_attr(feature = "full", ts(export))]
235 /// Get a list of banned persons.
236 // TODO, this should be paged, since the list can be quite long.
237 pub struct GetBannedPersons {
238 pub auth: Sensitive<String>,
241 #[derive(Debug, Serialize, Deserialize, Clone)]
242 #[cfg_attr(feature = "full", derive(TS))]
243 #[cfg_attr(feature = "full", ts(export))]
244 /// The list of banned persons.
245 pub struct BannedPersonsResponse {
246 pub banned: Vec<PersonView>,
249 #[derive(Debug, Serialize, Deserialize, Clone)]
250 #[cfg_attr(feature = "full", derive(TS))]
251 #[cfg_attr(feature = "full", ts(export))]
252 /// A response for a banned person.
253 pub struct BanPersonResponse {
254 pub person_view: PersonView,
258 #[derive(Debug, Serialize, Deserialize, Clone, Default)]
259 #[cfg_attr(feature = "full", derive(TS))]
260 #[cfg_attr(feature = "full", ts(export))]
262 pub struct BlockPerson {
263 pub person_id: PersonId,
265 pub auth: Sensitive<String>,
268 #[derive(Debug, Serialize, Deserialize, Clone)]
269 #[cfg_attr(feature = "full", derive(TS))]
270 #[cfg_attr(feature = "full", ts(export))]
271 /// The response for a person block.
272 pub struct BlockPersonResponse {
273 pub person_view: PersonView,
277 #[skip_serializing_none]
278 #[derive(Debug, Serialize, Deserialize, Clone, Default)]
279 #[cfg_attr(feature = "full", derive(TS))]
280 #[cfg_attr(feature = "full", ts(export))]
281 /// Get comment replies.
282 pub struct GetReplies {
283 pub sort: Option<CommentSortType>,
284 pub page: Option<i64>,
285 pub limit: Option<i64>,
286 pub unread_only: Option<bool>,
287 pub auth: Sensitive<String>,
290 #[derive(Debug, Serialize, Deserialize, Clone, Default)]
291 #[cfg_attr(feature = "full", derive(TS))]
292 #[cfg_attr(feature = "full", ts(export))]
293 /// Fetches your replies.
294 // TODO, replies and mentions below should be redone as tagged enums.
295 pub struct GetRepliesResponse {
296 pub replies: Vec<CommentReplyView>,
299 #[skip_serializing_none]
300 #[derive(Debug, Serialize, Deserialize, Clone, Default)]
301 #[cfg_attr(feature = "full", derive(TS))]
302 #[cfg_attr(feature = "full", ts(export))]
303 /// Get mentions for your user.
304 pub struct GetPersonMentions {
305 pub sort: Option<CommentSortType>,
306 pub page: Option<i64>,
307 pub limit: Option<i64>,
308 pub unread_only: Option<bool>,
309 pub auth: Sensitive<String>,
312 #[derive(Debug, Serialize, Deserialize, Clone)]
313 #[cfg_attr(feature = "full", derive(TS))]
314 #[cfg_attr(feature = "full", ts(export))]
315 /// The response of mentions for your user.
316 pub struct GetPersonMentionsResponse {
317 pub mentions: Vec<PersonMentionView>,
320 #[derive(Debug, Serialize, Deserialize, Clone, Default)]
321 #[cfg_attr(feature = "full", derive(TS))]
322 #[cfg_attr(feature = "full", ts(export))]
323 /// Mark a person mention as read.
324 pub struct MarkPersonMentionAsRead {
325 pub person_mention_id: PersonMentionId,
327 pub auth: Sensitive<String>,
330 #[derive(Debug, Serialize, Deserialize, Clone)]
331 #[cfg_attr(feature = "full", derive(TS))]
332 #[cfg_attr(feature = "full", ts(export))]
333 /// The response for a person mention action.
334 pub struct PersonMentionResponse {
335 pub person_mention_view: PersonMentionView,
338 #[derive(Debug, Serialize, Deserialize, Clone, Default)]
339 #[cfg_attr(feature = "full", derive(TS))]
340 #[cfg_attr(feature = "full", ts(export))]
341 /// Mark a comment reply as read.
342 pub struct MarkCommentReplyAsRead {
343 pub comment_reply_id: CommentReplyId,
345 pub auth: Sensitive<String>,
348 #[derive(Debug, Serialize, Deserialize, Clone)]
349 #[cfg_attr(feature = "full", derive(TS))]
350 #[cfg_attr(feature = "full", ts(export))]
351 /// The response for a comment reply action.
352 pub struct CommentReplyResponse {
353 pub comment_reply_view: CommentReplyView,
356 #[derive(Debug, Serialize, Deserialize, Clone, Default)]
357 #[cfg_attr(feature = "full", derive(TS))]
358 #[cfg_attr(feature = "full", ts(export))]
359 /// Delete your account.
360 pub struct DeleteAccount {
361 pub password: Sensitive<String>,
362 pub auth: Sensitive<String>,
365 #[derive(Debug, Serialize, Deserialize, Clone)]
366 #[cfg_attr(feature = "full", derive(TS))]
367 #[cfg_attr(feature = "full", ts(export))]
368 /// The response of deleting your account.
369 pub struct DeleteAccountResponse {}
371 #[derive(Debug, Serialize, Deserialize, Clone, Default)]
372 #[cfg_attr(feature = "full", derive(TS))]
373 #[cfg_attr(feature = "full", ts(export))]
374 /// Reset your password via email.
375 pub struct PasswordReset {
376 pub email: Sensitive<String>,
379 #[derive(Debug, Serialize, Deserialize, Clone)]
380 #[cfg_attr(feature = "full", derive(TS))]
381 #[cfg_attr(feature = "full", ts(export))]
382 /// The response of a password reset.
383 pub struct PasswordResetResponse {}
385 #[derive(Debug, Serialize, Deserialize, Clone, Default)]
386 #[cfg_attr(feature = "full", derive(TS))]
387 #[cfg_attr(feature = "full", ts(export))]
388 /// Change your password after receiving a reset request.
389 pub struct PasswordChangeAfterReset {
390 pub token: Sensitive<String>,
391 pub password: Sensitive<String>,
392 pub password_verify: Sensitive<String>,
395 #[skip_serializing_none]
396 #[derive(Debug, Serialize, Deserialize, Clone, Default)]
397 #[cfg_attr(feature = "full", derive(TS))]
398 #[cfg_attr(feature = "full", ts(export))]
399 /// Get a count of the number of reports.
400 pub struct GetReportCount {
401 pub community_id: Option<CommunityId>,
402 pub auth: Sensitive<String>,
405 #[skip_serializing_none]
406 #[derive(Debug, Serialize, Deserialize, Clone)]
407 #[cfg_attr(feature = "full", derive(TS))]
408 #[cfg_attr(feature = "full", ts(export))]
409 /// A response for the number of reports.
410 pub struct GetReportCountResponse {
411 pub community_id: Option<CommunityId>,
412 pub comment_reports: i64,
413 pub post_reports: i64,
414 pub private_message_reports: Option<i64>,
417 #[derive(Debug, Serialize, Deserialize, Clone, Default)]
418 #[cfg_attr(feature = "full", derive(TS))]
419 #[cfg_attr(feature = "full", ts(export))]
420 /// Get a count of unread notifications.
421 pub struct GetUnreadCount {
422 pub auth: Sensitive<String>,
425 #[derive(Debug, Serialize, Deserialize, Clone)]
426 #[cfg_attr(feature = "full", derive(TS))]
427 #[cfg_attr(feature = "full", ts(export))]
428 /// A response containing counts for your notifications.
429 pub struct GetUnreadCountResponse {
432 pub private_messages: i64,
435 #[derive(Serialize, Deserialize, Clone, Default, Debug)]
436 #[cfg_attr(feature = "full", derive(TS))]
437 #[cfg_attr(feature = "full", ts(export))]
438 /// Verify your email.
439 pub struct VerifyEmail {
443 #[derive(Debug, Serialize, Deserialize, Clone)]
444 #[cfg_attr(feature = "full", derive(TS))]
445 #[cfg_attr(feature = "full", ts(export))]
446 /// A response to verifying your email.
447 pub struct VerifyEmailResponse {}