1 use crate::sensitive::Sensitive;
3 newtypes::{CommentReplyId, CommunityId, LanguageId, PersonId, PersonMentionId},
7 use lemmy_db_views::structs::{CommentView, PostView};
8 use lemmy_db_views_actor::structs::{
10 CommunityModeratorView,
14 use serde::{Deserialize, Serialize};
16 #[derive(Debug, Serialize, Deserialize, Clone, Default)]
18 pub username_or_email: Sensitive<String>,
19 pub password: Sensitive<String>,
20 pub totp_2fa_token: Option<String>,
23 #[derive(Debug, Serialize, Deserialize, Clone, Default)]
26 pub password: Sensitive<String>,
27 pub password_verify: Sensitive<String>,
29 /// email is mandatory if email verification is enabled on the server
30 pub email: Option<Sensitive<String>>,
31 pub captcha_uuid: Option<String>,
32 pub captcha_answer: Option<String>,
33 pub honeypot: Option<String>,
34 /// An answer is mandatory if require application is enabled on the server
35 pub answer: Option<String>,
38 #[derive(Debug, Serialize, Deserialize, Clone, Default)]
39 pub struct GetCaptcha {}
41 #[derive(Debug, Serialize, Deserialize, Clone)]
42 pub struct GetCaptchaResponse {
43 pub ok: Option<CaptchaResponse>, // Will be None if captchas are disabled
46 #[derive(Debug, Serialize, Deserialize, Clone)]
47 pub struct CaptchaResponse {
48 pub png: String, // A Base64 encoded png
49 pub wav: String, // A Base64 encoded wav audio
53 #[derive(Debug, Serialize, Deserialize, Clone, Default)]
54 pub struct SaveUserSettings {
55 pub show_nsfw: Option<bool>,
56 pub show_scores: Option<bool>,
57 pub theme: Option<String>,
58 pub default_sort_type: Option<i16>,
59 pub default_listing_type: Option<i16>,
60 pub interface_language: Option<String>,
61 pub avatar: Option<String>,
62 pub banner: Option<String>,
63 pub display_name: Option<String>,
64 pub email: Option<Sensitive<String>>,
65 pub bio: Option<String>,
66 pub matrix_user_id: Option<String>,
67 pub show_avatars: Option<bool>,
68 pub send_notifications_to_email: Option<bool>,
69 pub bot_account: Option<bool>,
70 pub show_bot_accounts: Option<bool>,
71 pub show_read_posts: Option<bool>,
72 pub show_new_post_notifs: Option<bool>,
73 pub discussion_languages: Option<Vec<LanguageId>>,
74 /// None leaves it as is, true will generate or regenerate it, false clears it out
75 pub generate_totp_2fa: Option<bool>,
76 pub auth: Sensitive<String>,
79 #[derive(Debug, Serialize, Deserialize, Clone, Default)]
80 pub struct ChangePassword {
81 pub new_password: Sensitive<String>,
82 pub new_password_verify: Sensitive<String>,
83 pub old_password: Sensitive<String>,
84 pub auth: Sensitive<String>,
87 #[derive(Debug, Serialize, Deserialize, Clone)]
88 pub struct LoginResponse {
89 /// This is None in response to `Register` if email verification is enabled, or the server requires registration applications.
90 pub jwt: Option<Sensitive<String>>,
91 pub registration_created: bool,
92 pub verify_email_sent: bool,
95 #[derive(Debug, Serialize, Deserialize, Clone, Default)]
96 pub struct GetPersonDetails {
97 pub person_id: Option<PersonId>, // One of these two are required
98 /// Example: dessalines , or dessalines@xyz.tld
99 pub username: Option<String>,
100 pub sort: Option<SortType>,
101 pub page: Option<i64>,
102 pub limit: Option<i64>,
103 pub community_id: Option<CommunityId>,
104 pub saved_only: Option<bool>,
105 pub auth: Option<Sensitive<String>>,
108 #[derive(Debug, Serialize, Deserialize, Clone)]
109 pub struct GetPersonDetailsResponse {
110 pub person_view: PersonView,
111 pub comments: Vec<CommentView>,
112 pub posts: Vec<PostView>,
113 pub moderates: Vec<CommunityModeratorView>,
116 #[derive(Debug, Serialize, Deserialize, Clone, Default)]
117 pub struct GetRepliesResponse {
118 pub replies: Vec<CommentReplyView>,
121 #[derive(Debug, Serialize, Deserialize, Clone)]
122 pub struct GetPersonMentionsResponse {
123 pub mentions: Vec<PersonMentionView>,
126 #[derive(Debug, Serialize, Deserialize, Clone, Default)]
127 pub struct MarkAllAsRead {
128 pub auth: Sensitive<String>,
131 #[derive(Debug, Serialize, Deserialize, Clone, Default)]
132 pub struct AddAdmin {
133 pub person_id: PersonId,
135 pub auth: Sensitive<String>,
138 #[derive(Debug, Serialize, Deserialize, Clone)]
139 pub struct AddAdminResponse {
140 pub admins: Vec<PersonView>,
143 #[derive(Debug, Serialize, Deserialize, Clone, Default)]
144 pub struct BanPerson {
145 pub person_id: PersonId,
147 pub remove_data: Option<bool>,
148 pub reason: Option<String>,
149 pub expires: Option<i64>,
150 pub auth: Sensitive<String>,
153 #[derive(Debug, Serialize, Deserialize, Clone, Default)]
154 pub struct GetBannedPersons {
158 #[derive(Debug, Serialize, Deserialize, Clone)]
159 pub struct BannedPersonsResponse {
160 pub banned: Vec<PersonView>,
163 #[derive(Debug, Serialize, Deserialize, Clone)]
164 pub struct BanPersonResponse {
165 pub person_view: PersonView,
169 #[derive(Debug, Serialize, Deserialize, Clone, Default)]
170 pub struct BlockPerson {
171 pub person_id: PersonId,
173 pub auth: Sensitive<String>,
176 #[derive(Debug, Serialize, Deserialize, Clone)]
177 pub struct BlockPersonResponse {
178 pub person_view: PersonView,
182 #[derive(Debug, Serialize, Deserialize, Clone, Default)]
183 pub struct GetReplies {
184 pub sort: Option<CommentSortType>,
185 pub page: Option<i64>,
186 pub limit: Option<i64>,
187 pub unread_only: Option<bool>,
188 pub auth: Sensitive<String>,
191 #[derive(Debug, Serialize, Deserialize, Clone, Default)]
192 pub struct GetPersonMentions {
193 pub sort: Option<CommentSortType>,
194 pub page: Option<i64>,
195 pub limit: Option<i64>,
196 pub unread_only: Option<bool>,
197 pub auth: Sensitive<String>,
200 #[derive(Debug, Serialize, Deserialize, Clone, Default)]
201 pub struct MarkPersonMentionAsRead {
202 pub person_mention_id: PersonMentionId,
204 pub auth: Sensitive<String>,
207 #[derive(Debug, Serialize, Deserialize, Clone)]
208 pub struct PersonMentionResponse {
209 pub person_mention_view: PersonMentionView,
212 #[derive(Debug, Serialize, Deserialize, Clone, Default)]
213 pub struct MarkCommentReplyAsRead {
214 pub comment_reply_id: CommentReplyId,
216 pub auth: Sensitive<String>,
219 #[derive(Debug, Serialize, Deserialize, Clone)]
220 pub struct CommentReplyResponse {
221 pub comment_reply_view: CommentReplyView,
224 #[derive(Debug, Serialize, Deserialize, Clone, Default)]
225 pub struct DeleteAccount {
226 pub password: Sensitive<String>,
227 pub auth: Sensitive<String>,
230 #[derive(Debug, Serialize, Deserialize, Clone)]
231 pub struct DeleteAccountResponse {}
233 #[derive(Debug, Serialize, Deserialize, Clone, Default)]
234 pub struct PasswordReset {
235 pub email: Sensitive<String>,
238 #[derive(Debug, Serialize, Deserialize, Clone)]
239 pub struct PasswordResetResponse {}
241 #[derive(Debug, Serialize, Deserialize, Clone, Default)]
242 pub struct PasswordChangeAfterReset {
243 pub token: Sensitive<String>,
244 pub password: Sensitive<String>,
245 pub password_verify: Sensitive<String>,
248 #[derive(Debug, Serialize, Deserialize, Clone, Default)]
249 pub struct GetReportCount {
250 pub community_id: Option<CommunityId>,
251 pub auth: Sensitive<String>,
254 #[derive(Debug, Serialize, Deserialize, Clone)]
255 pub struct GetReportCountResponse {
256 pub community_id: Option<CommunityId>,
257 pub comment_reports: i64,
258 pub post_reports: i64,
259 pub private_message_reports: Option<i64>,
262 #[derive(Debug, Serialize, Deserialize, Clone, Default)]
263 pub struct GetUnreadCount {
264 pub auth: Sensitive<String>,
267 #[derive(Debug, Serialize, Deserialize, Clone)]
268 pub struct GetUnreadCountResponse {
271 pub private_messages: i64,
274 #[derive(Serialize, Deserialize, Clone, Default, Debug)]
275 pub struct VerifyEmail {
279 #[derive(Debug, Serialize, Deserialize, Clone)]
280 pub struct VerifyEmailResponse {}