]> Untitled Git - lemmy.git/blob - crates/api_common/src/person.rs
5dddc5dcceb6f7511517dcf24efcd25b0dfec6e4
[lemmy.git] / crates / api_common / src / person.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_moderator_view::CommunityModeratorView,
8   person_mention_view::PersonMentionView,
9   person_view::PersonViewSafe,
10 };
11 use lemmy_utils::Sensitive;
12 use serde::{Deserialize, Serialize};
13
14 #[derive(Debug, Serialize, Deserialize)]
15 pub struct Login {
16   pub username_or_email: Sensitive<String>,
17   pub password: Sensitive<String>,
18 }
19 use lemmy_db_schema::newtypes::{CommunityId, PersonId, PersonMentionId, PrivateMessageId};
20
21 #[derive(Debug, Serialize, Deserialize)]
22 pub struct Register {
23   pub username: String,
24   pub password: Sensitive<String>,
25   pub password_verify: Sensitive<String>,
26   pub show_nsfw: bool,
27   pub email: Option<Sensitive<String>>,
28   pub captcha_uuid: Option<String>,
29   pub captcha_answer: Option<String>,
30   pub honeypot: Option<String>,
31 }
32
33 #[derive(Debug, Serialize, Deserialize)]
34 pub struct GetCaptcha {}
35
36 #[derive(Debug, Serialize, Deserialize)]
37 pub struct GetCaptchaResponse {
38   pub ok: Option<CaptchaResponse>, // Will be None if captchas are disabled
39 }
40
41 #[derive(Debug, Serialize, Deserialize)]
42 pub struct CaptchaResponse {
43   pub png: String, // A Base64 encoded png
44   pub wav: String, // A Base64 encoded wav audio
45   pub uuid: String,
46 }
47
48 #[derive(Debug, Serialize, Deserialize)]
49 pub struct SaveUserSettings {
50   pub show_nsfw: Option<bool>,
51   pub show_scores: Option<bool>,
52   pub theme: Option<String>,
53   pub default_sort_type: Option<i16>,
54   pub default_listing_type: Option<i16>,
55   pub lang: Option<String>,
56   pub avatar: Option<String>,
57   pub banner: Option<String>,
58   pub display_name: Option<String>,
59   pub email: Option<Sensitive<String>>,
60   pub bio: Option<String>,
61   pub matrix_user_id: Option<String>,
62   pub show_avatars: Option<bool>,
63   pub send_notifications_to_email: Option<bool>,
64   pub bot_account: Option<bool>,
65   pub show_bot_accounts: Option<bool>,
66   pub show_read_posts: Option<bool>,
67   pub show_new_post_notifs: Option<bool>,
68   pub auth: Sensitive<String>,
69 }
70
71 #[derive(Debug, Serialize, Deserialize)]
72 pub struct ChangePassword {
73   pub new_password: Sensitive<String>,
74   pub new_password_verify: Sensitive<String>,
75   pub old_password: Sensitive<String>,
76   pub auth: Sensitive<String>,
77 }
78
79 #[derive(Debug, Serialize, Deserialize)]
80 pub struct LoginResponse {
81   pub jwt: Sensitive<String>,
82 }
83
84 #[derive(Debug, Serialize, Deserialize)]
85 pub struct GetPersonDetails {
86   pub person_id: Option<PersonId>, // One of these two are required
87   /// Example: dessalines , or dessalines@xyz.tld
88   pub username: Option<String>,
89   pub sort: Option<String>,
90   pub page: Option<i64>,
91   pub limit: Option<i64>,
92   pub community_id: Option<CommunityId>,
93   pub saved_only: Option<bool>,
94   pub auth: Option<Sensitive<String>>,
95 }
96
97 #[derive(Debug, Serialize, Deserialize)]
98 pub struct GetPersonDetailsResponse {
99   pub person_view: PersonViewSafe,
100   pub comments: Vec<CommentView>,
101   pub posts: Vec<PostView>,
102   pub moderates: Vec<CommunityModeratorView>,
103 }
104
105 #[derive(Debug, Serialize, Deserialize)]
106 pub struct GetRepliesResponse {
107   pub replies: Vec<CommentView>,
108 }
109
110 #[derive(Debug, Serialize, Deserialize)]
111 pub struct GetPersonMentionsResponse {
112   pub mentions: Vec<PersonMentionView>,
113 }
114
115 #[derive(Debug, Serialize, Deserialize)]
116 pub struct MarkAllAsRead {
117   pub auth: Sensitive<String>,
118 }
119
120 #[derive(Debug, Serialize, Deserialize)]
121 pub struct AddAdmin {
122   pub person_id: PersonId,
123   pub added: bool,
124   pub auth: Sensitive<String>,
125 }
126
127 #[derive(Debug, Serialize, Deserialize, Clone)]
128 pub struct AddAdminResponse {
129   pub admins: Vec<PersonViewSafe>,
130 }
131
132 #[derive(Debug, Serialize, Deserialize)]
133 pub struct BanPerson {
134   pub person_id: PersonId,
135   pub ban: bool,
136   pub remove_data: Option<bool>,
137   pub reason: Option<String>,
138   pub expires: Option<i64>,
139   pub auth: Sensitive<String>,
140 }
141
142 #[derive(Debug, Serialize, Deserialize, Clone)]
143 pub struct BanPersonResponse {
144   pub person_view: PersonViewSafe,
145   pub banned: bool,
146 }
147
148 #[derive(Debug, Serialize, Deserialize)]
149 pub struct BlockPerson {
150   pub person_id: PersonId,
151   pub block: bool,
152   pub auth: Sensitive<String>,
153 }
154
155 #[derive(Debug, Serialize, Deserialize, Clone)]
156 pub struct BlockPersonResponse {
157   pub person_view: PersonViewSafe,
158   pub blocked: bool,
159 }
160
161 #[derive(Debug, Serialize, Deserialize)]
162 pub struct GetReplies {
163   pub sort: Option<String>,
164   pub page: Option<i64>,
165   pub limit: Option<i64>,
166   pub unread_only: Option<bool>,
167   pub auth: Sensitive<String>,
168 }
169
170 #[derive(Debug, Serialize, Deserialize)]
171 pub struct GetPersonMentions {
172   pub sort: Option<String>,
173   pub page: Option<i64>,
174   pub limit: Option<i64>,
175   pub unread_only: Option<bool>,
176   pub auth: Sensitive<String>,
177 }
178
179 #[derive(Debug, Serialize, Deserialize)]
180 pub struct MarkPersonMentionAsRead {
181   pub person_mention_id: PersonMentionId,
182   pub read: bool,
183   pub auth: Sensitive<String>,
184 }
185
186 #[derive(Debug, Serialize, Deserialize, Clone)]
187 pub struct PersonMentionResponse {
188   pub person_mention_view: PersonMentionView,
189 }
190
191 #[derive(Debug, Serialize, Deserialize)]
192 pub struct DeleteAccount {
193   pub password: Sensitive<String>,
194   pub auth: Sensitive<String>,
195 }
196
197 #[derive(Debug, Serialize, Deserialize)]
198 pub struct PasswordReset {
199   pub email: Sensitive<String>,
200 }
201
202 #[derive(Debug, Serialize, Deserialize, Clone)]
203 pub struct PasswordResetResponse {}
204
205 #[derive(Debug, Serialize, Deserialize)]
206 pub struct PasswordChange {
207   pub token: Sensitive<String>,
208   pub password: Sensitive<String>,
209   pub password_verify: Sensitive<String>,
210 }
211
212 #[derive(Debug, Serialize, Deserialize)]
213 pub struct CreatePrivateMessage {
214   pub content: String,
215   pub recipient_id: PersonId,
216   pub auth: Sensitive<String>,
217 }
218
219 #[derive(Debug, Serialize, Deserialize)]
220 pub struct EditPrivateMessage {
221   pub private_message_id: PrivateMessageId,
222   pub content: String,
223   pub auth: Sensitive<String>,
224 }
225
226 #[derive(Debug, Serialize, Deserialize)]
227 pub struct DeletePrivateMessage {
228   pub private_message_id: PrivateMessageId,
229   pub deleted: bool,
230   pub auth: Sensitive<String>,
231 }
232
233 #[derive(Debug, Serialize, Deserialize)]
234 pub struct MarkPrivateMessageAsRead {
235   pub private_message_id: PrivateMessageId,
236   pub read: bool,
237   pub auth: Sensitive<String>,
238 }
239
240 #[derive(Debug, Serialize, Deserialize)]
241 pub struct GetPrivateMessages {
242   pub unread_only: Option<bool>,
243   pub page: Option<i64>,
244   pub limit: Option<i64>,
245   pub auth: Sensitive<String>,
246 }
247
248 #[derive(Debug, Serialize, Deserialize, Clone)]
249 pub struct PrivateMessagesResponse {
250   pub private_messages: Vec<PrivateMessageView>,
251 }
252
253 #[derive(Debug, Serialize, Deserialize, Clone)]
254 pub struct PrivateMessageResponse {
255   pub private_message_view: PrivateMessageView,
256 }
257
258 #[derive(Debug, Serialize, Deserialize)]
259 pub struct GetReportCount {
260   pub community_id: Option<CommunityId>,
261   pub auth: Sensitive<String>,
262 }
263
264 #[derive(Debug, Serialize, Deserialize, Clone)]
265 pub struct GetReportCountResponse {
266   pub community_id: Option<CommunityId>,
267   pub comment_reports: i64,
268   pub post_reports: i64,
269 }
270
271 #[derive(Debug, Serialize, Deserialize)]
272 pub struct GetUnreadCount {
273   pub auth: Sensitive<String>,
274 }
275
276 #[derive(Debug, Serialize, Deserialize, Clone)]
277 pub struct GetUnreadCountResponse {
278   pub replies: i64,
279   pub mentions: i64,
280   pub private_messages: i64,
281 }