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