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 auth: Option<Sensitive<String>>,
105 #[derive(Debug, Serialize, Deserialize, Clone)]
106 pub struct GetPersonDetailsResponse {
107 pub person_view: PersonView,
108 pub comments: Vec<CommentView>,
109 pub posts: Vec<PostView>,
110 pub moderates: Vec<CommunityModeratorView>,
113 #[derive(Debug, Serialize, Deserialize, Clone, Default)]
114 pub struct GetRepliesResponse {
115 pub replies: Vec<CommentReplyView>,
118 #[derive(Debug, Serialize, Deserialize, Clone)]
119 pub struct GetPersonMentionsResponse {
120 pub mentions: Vec<PersonMentionView>,
123 #[derive(Debug, Serialize, Deserialize, Clone, Default)]
124 pub struct MarkAllAsRead {
125 pub auth: Sensitive<String>,
128 #[derive(Debug, Serialize, Deserialize, Clone, Default)]
129 pub struct AddAdmin {
130 pub person_id: PersonId,
132 pub auth: Sensitive<String>,
135 #[derive(Debug, Serialize, Deserialize, Clone)]
136 pub struct AddAdminResponse {
137 pub admins: Vec<PersonView>,
140 #[derive(Debug, Serialize, Deserialize, Clone, Default)]
141 pub struct BanPerson {
142 pub person_id: PersonId,
144 pub remove_data: Option<bool>,
145 pub reason: Option<String>,
146 pub expires: Option<i64>,
147 pub auth: Sensitive<String>,
150 #[derive(Debug, Serialize, Deserialize, Clone, Default)]
151 pub struct GetBannedPersons {
155 #[derive(Debug, Serialize, Deserialize, Clone)]
156 pub struct BannedPersonsResponse {
157 pub banned: Vec<PersonView>,
160 #[derive(Debug, Serialize, Deserialize, Clone)]
161 pub struct BanPersonResponse {
162 pub person_view: PersonView,
166 #[derive(Debug, Serialize, Deserialize, Clone, Default)]
167 pub struct BlockPerson {
168 pub person_id: PersonId,
170 pub auth: Sensitive<String>,
173 #[derive(Debug, Serialize, Deserialize, Clone)]
174 pub struct BlockPersonResponse {
175 pub person_view: PersonView,
179 #[derive(Debug, Serialize, Deserialize, Clone, Default)]
180 pub struct GetReplies {
181 pub sort: Option<CommentSortType>,
182 pub page: Option<i64>,
183 pub limit: Option<i64>,
184 pub unread_only: Option<bool>,
185 pub auth: Sensitive<String>,
188 #[derive(Debug, Serialize, Deserialize, Clone, Default)]
189 pub struct GetPersonMentions {
190 pub sort: Option<CommentSortType>,
191 pub page: Option<i64>,
192 pub limit: Option<i64>,
193 pub unread_only: Option<bool>,
194 pub auth: Sensitive<String>,
197 #[derive(Debug, Serialize, Deserialize, Clone, Default)]
198 pub struct MarkPersonMentionAsRead {
199 pub person_mention_id: PersonMentionId,
201 pub auth: Sensitive<String>,
204 #[derive(Debug, Serialize, Deserialize, Clone)]
205 pub struct PersonMentionResponse {
206 pub person_mention_view: PersonMentionView,
209 #[derive(Debug, Serialize, Deserialize, Clone, Default)]
210 pub struct MarkCommentReplyAsRead {
211 pub comment_reply_id: CommentReplyId,
213 pub auth: Sensitive<String>,
216 #[derive(Debug, Serialize, Deserialize, Clone)]
217 pub struct CommentReplyResponse {
218 pub comment_reply_view: CommentReplyView,
221 #[derive(Debug, Serialize, Deserialize, Clone, Default)]
222 pub struct DeleteAccount {
223 pub password: Sensitive<String>,
224 pub auth: Sensitive<String>,
227 #[derive(Debug, Serialize, Deserialize, Clone)]
228 pub struct DeleteAccountResponse {}
230 #[derive(Debug, Serialize, Deserialize, Clone, Default)]
231 pub struct PasswordReset {
232 pub email: Sensitive<String>,
235 #[derive(Debug, Serialize, Deserialize, Clone)]
236 pub struct PasswordResetResponse {}
238 #[derive(Debug, Serialize, Deserialize, Clone, Default)]
239 pub struct PasswordChangeAfterReset {
240 pub token: Sensitive<String>,
241 pub password: Sensitive<String>,
242 pub password_verify: Sensitive<String>,
245 #[derive(Debug, Serialize, Deserialize, Clone, Default)]
246 pub struct GetReportCount {
247 pub community_id: Option<CommunityId>,
248 pub auth: Sensitive<String>,
251 #[derive(Debug, Serialize, Deserialize, Clone)]
252 pub struct GetReportCountResponse {
253 pub community_id: Option<CommunityId>,
254 pub comment_reports: i64,
255 pub post_reports: i64,
256 pub private_message_reports: Option<i64>,
259 #[derive(Debug, Serialize, Deserialize, Clone, Default)]
260 pub struct GetUnreadCount {
261 pub auth: Sensitive<String>,
264 #[derive(Debug, Serialize, Deserialize, Clone)]
265 pub struct GetUnreadCountResponse {
268 pub private_messages: i64,
271 #[derive(Serialize, Deserialize, Clone, Default, Debug)]
272 pub struct VerifyEmail {
276 #[derive(Debug, Serialize, Deserialize, Clone)]
277 pub struct VerifyEmailResponse {}