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>,
22 #[derive(Debug, Serialize, Deserialize, Clone, Default)]
25 pub password: Sensitive<String>,
26 pub password_verify: Sensitive<String>,
28 /// email is mandatory if email verification is enabled on the server
29 pub email: Option<Sensitive<String>>,
30 pub captcha_uuid: Option<String>,
31 pub captcha_answer: Option<String>,
32 pub honeypot: Option<String>,
33 /// An answer is mandatory if require application is enabled on the server
34 pub answer: Option<String>,
37 #[derive(Debug, Serialize, Deserialize, Clone, Default)]
38 pub struct GetCaptcha {}
40 #[derive(Debug, Serialize, Deserialize, Clone)]
41 pub struct GetCaptchaResponse {
42 pub ok: Option<CaptchaResponse>, // Will be None if captchas are disabled
45 #[derive(Debug, Serialize, Deserialize, Clone)]
46 pub struct CaptchaResponse {
47 pub png: String, // A Base64 encoded png
48 pub wav: String, // A Base64 encoded wav audio
52 #[derive(Debug, Serialize, Deserialize, Clone, Default)]
53 pub struct SaveUserSettings {
54 pub show_nsfw: Option<bool>,
55 pub show_scores: Option<bool>,
56 pub theme: Option<String>,
57 pub default_sort_type: Option<i16>,
58 pub default_listing_type: Option<i16>,
59 pub interface_language: Option<String>,
60 pub avatar: Option<String>,
61 pub banner: Option<String>,
62 pub display_name: Option<String>,
63 pub email: Option<Sensitive<String>>,
64 pub bio: Option<String>,
65 pub matrix_user_id: Option<String>,
66 pub show_avatars: Option<bool>,
67 pub send_notifications_to_email: Option<bool>,
68 pub bot_account: Option<bool>,
69 pub show_bot_accounts: Option<bool>,
70 pub show_read_posts: Option<bool>,
71 pub show_new_post_notifs: Option<bool>,
72 pub discussion_languages: Option<Vec<LanguageId>>,
73 pub auth: Sensitive<String>,
76 #[derive(Debug, Serialize, Deserialize, Clone, Default)]
77 pub struct ChangePassword {
78 pub new_password: Sensitive<String>,
79 pub new_password_verify: Sensitive<String>,
80 pub old_password: Sensitive<String>,
81 pub auth: Sensitive<String>,
84 #[derive(Debug, Serialize, Deserialize, Clone)]
85 pub struct LoginResponse {
86 /// This is None in response to `Register` if email verification is enabled, or the server requires registration applications.
87 pub jwt: Option<Sensitive<String>>,
88 pub registration_created: bool,
89 pub verify_email_sent: bool,
92 #[derive(Debug, Serialize, Deserialize, Clone, Default)]
93 pub struct GetPersonDetails {
94 pub person_id: Option<PersonId>, // One of these two are required
95 /// Example: dessalines , or dessalines@xyz.tld
96 pub username: Option<String>,
97 pub sort: Option<SortType>,
98 pub page: Option<i64>,
99 pub limit: Option<i64>,
100 pub community_id: Option<CommunityId>,
101 pub saved_only: Option<bool>,
102 pub show_deleted_and_removed: Option<bool>,
103 pub auth: Option<Sensitive<String>>,
106 #[derive(Debug, Serialize, Deserialize, Clone)]
107 pub struct GetPersonDetailsResponse {
108 pub person_view: PersonViewSafe,
109 pub comments: Vec<CommentView>,
110 pub posts: Vec<PostView>,
111 pub moderates: Vec<CommunityModeratorView>,
114 #[derive(Debug, Serialize, Deserialize, Clone, Default)]
115 pub struct GetRepliesResponse {
116 pub replies: Vec<CommentReplyView>,
119 #[derive(Debug, Serialize, Deserialize, Clone)]
120 pub struct GetPersonMentionsResponse {
121 pub mentions: Vec<PersonMentionView>,
124 #[derive(Debug, Serialize, Deserialize, Clone, Default)]
125 pub struct MarkAllAsRead {
126 pub auth: Sensitive<String>,
129 #[derive(Debug, Serialize, Deserialize, Clone, Default)]
130 pub struct AddAdmin {
131 pub person_id: PersonId,
133 pub auth: Sensitive<String>,
136 #[derive(Debug, Serialize, Deserialize, Clone)]
137 pub struct AddAdminResponse {
138 pub admins: Vec<PersonViewSafe>,
141 #[derive(Debug, Serialize, Deserialize, Clone, Default)]
142 pub struct BanPerson {
143 pub person_id: PersonId,
145 pub remove_data: Option<bool>,
146 pub reason: Option<String>,
147 pub expires: Option<i64>,
148 pub auth: Sensitive<String>,
151 #[derive(Debug, Serialize, Deserialize, Clone, Default)]
152 pub struct GetBannedPersons {
156 #[derive(Debug, Serialize, Deserialize, Clone)]
157 pub struct BannedPersonsResponse {
158 pub banned: Vec<PersonViewSafe>,
161 #[derive(Debug, Serialize, Deserialize, Clone)]
162 pub struct BanPersonResponse {
163 pub person_view: PersonViewSafe,
167 #[derive(Debug, Serialize, Deserialize, Clone, Default)]
168 pub struct BlockPerson {
169 pub person_id: PersonId,
171 pub auth: Sensitive<String>,
174 #[derive(Debug, Serialize, Deserialize, Clone)]
175 pub struct BlockPersonResponse {
176 pub person_view: PersonViewSafe,
180 #[derive(Debug, Serialize, Deserialize, Clone, Default)]
181 pub struct GetReplies {
182 pub sort: Option<CommentSortType>,
183 pub page: Option<i64>,
184 pub limit: Option<i64>,
185 pub unread_only: Option<bool>,
186 pub auth: Sensitive<String>,
189 #[derive(Debug, Serialize, Deserialize, Clone, Default)]
190 pub struct GetPersonMentions {
191 pub sort: Option<CommentSortType>,
192 pub page: Option<i64>,
193 pub limit: Option<i64>,
194 pub unread_only: Option<bool>,
195 pub auth: Sensitive<String>,
198 #[derive(Debug, Serialize, Deserialize, Clone, Default)]
199 pub struct MarkPersonMentionAsRead {
200 pub person_mention_id: PersonMentionId,
202 pub auth: Sensitive<String>,
205 #[derive(Debug, Serialize, Deserialize, Clone)]
206 pub struct PersonMentionResponse {
207 pub person_mention_view: PersonMentionView,
210 #[derive(Debug, Serialize, Deserialize, Clone, Default)]
211 pub struct MarkCommentReplyAsRead {
212 pub comment_reply_id: CommentReplyId,
214 pub auth: Sensitive<String>,
217 #[derive(Debug, Serialize, Deserialize, Clone)]
218 pub struct CommentReplyResponse {
219 pub comment_reply_view: CommentReplyView,
222 #[derive(Debug, Serialize, Deserialize, Clone, Default)]
223 pub struct DeleteAccount {
224 pub password: Sensitive<String>,
225 pub auth: Sensitive<String>,
228 #[derive(Debug, Serialize, Deserialize, Clone)]
229 pub struct DeleteAccountResponse {}
231 #[derive(Debug, Serialize, Deserialize, Clone, Default)]
232 pub struct PasswordReset {
233 pub email: Sensitive<String>,
236 #[derive(Debug, Serialize, Deserialize, Clone)]
237 pub struct PasswordResetResponse {}
239 #[derive(Debug, Serialize, Deserialize, Clone, Default)]
240 pub struct PasswordChangeAfterReset {
241 pub token: Sensitive<String>,
242 pub password: Sensitive<String>,
243 pub password_verify: Sensitive<String>,
246 #[derive(Debug, Serialize, Deserialize, Clone, Default)]
247 pub struct GetReportCount {
248 pub community_id: Option<CommunityId>,
249 pub auth: Sensitive<String>,
252 #[derive(Debug, Serialize, Deserialize, Clone)]
253 pub struct GetReportCountResponse {
254 pub community_id: Option<CommunityId>,
255 pub comment_reports: i64,
256 pub post_reports: i64,
257 pub private_message_reports: Option<i64>,
260 #[derive(Debug, Serialize, Deserialize, Clone, Default)]
261 pub struct GetUnreadCount {
262 pub auth: Sensitive<String>,
265 #[derive(Debug, Serialize, Deserialize, Clone)]
266 pub struct GetUnreadCountResponse {
269 pub private_messages: i64,
272 #[derive(Serialize, Deserialize, Clone, Default)]
273 pub struct VerifyEmail {
277 #[derive(Debug, Serialize, Deserialize, Clone)]
278 pub struct VerifyEmailResponse {}