]> Untitled Git - lemmy.git/blob - crates/api_common/src/person.rs
Merge pull request #1537 from LemmyNet/add_users_active_monthly_community_sort
[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: 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 show_scores: Option<bool>,
51   pub show_avatars: 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<String>,
60   pub bio: Option<String>,
61   pub matrix_user_id: Option<String>,
62   pub new_password: Option<String>,
63   pub new_password_verify: Option<String>,
64   pub old_password: Option<String>,
65   pub send_notifications_to_email: Option<bool>,
66   pub auth: String,
67 }
68
69 #[derive(Serialize)]
70 pub struct LoginResponse {
71   pub jwt: String,
72 }
73
74 #[derive(Deserialize)]
75 pub struct GetPersonDetails {
76   pub person_id: Option<PersonId>,
77   pub username: Option<String>,
78   pub sort: String,
79   pub page: Option<i64>,
80   pub limit: Option<i64>,
81   pub community_id: Option<CommunityId>,
82   pub saved_only: bool,
83   pub auth: Option<String>,
84 }
85
86 #[derive(Serialize)]
87 pub struct GetPersonDetailsResponse {
88   pub person_view: PersonViewSafe,
89   pub follows: Vec<CommunityFollowerView>,
90   pub moderates: Vec<CommunityModeratorView>,
91   pub comments: Vec<CommentView>,
92   pub posts: Vec<PostView>,
93 }
94
95 #[derive(Serialize)]
96 pub struct GetRepliesResponse {
97   pub replies: Vec<CommentView>,
98 }
99
100 #[derive(Serialize)]
101 pub struct GetPersonMentionsResponse {
102   pub mentions: Vec<PersonMentionView>,
103 }
104
105 #[derive(Deserialize)]
106 pub struct MarkAllAsRead {
107   pub auth: String,
108 }
109
110 #[derive(Deserialize)]
111 pub struct AddAdmin {
112   pub person_id: PersonId,
113   pub added: bool,
114   pub auth: String,
115 }
116
117 #[derive(Serialize, Clone)]
118 pub struct AddAdminResponse {
119   pub admins: Vec<PersonViewSafe>,
120 }
121
122 #[derive(Deserialize)]
123 pub struct BanPerson {
124   pub person_id: PersonId,
125   pub ban: bool,
126   pub remove_data: bool,
127   pub reason: Option<String>,
128   pub expires: Option<i64>,
129   pub auth: String,
130 }
131
132 #[derive(Serialize, Clone)]
133 pub struct BanPersonResponse {
134   pub person_view: PersonViewSafe,
135   pub banned: bool,
136 }
137
138 #[derive(Deserialize)]
139 pub struct GetReplies {
140   pub sort: String,
141   pub page: Option<i64>,
142   pub limit: Option<i64>,
143   pub unread_only: bool,
144   pub auth: String,
145 }
146
147 #[derive(Deserialize)]
148 pub struct GetPersonMentions {
149   pub sort: String,
150   pub page: Option<i64>,
151   pub limit: Option<i64>,
152   pub unread_only: bool,
153   pub auth: String,
154 }
155
156 #[derive(Deserialize)]
157 pub struct MarkPersonMentionAsRead {
158   pub person_mention_id: PersonMentionId,
159   pub read: bool,
160   pub auth: String,
161 }
162
163 #[derive(Serialize, Clone)]
164 pub struct PersonMentionResponse {
165   pub person_mention_view: PersonMentionView,
166 }
167
168 #[derive(Deserialize)]
169 pub struct DeleteAccount {
170   pub password: String,
171   pub auth: String,
172 }
173
174 #[derive(Deserialize)]
175 pub struct PasswordReset {
176   pub email: String,
177 }
178
179 #[derive(Serialize, Clone)]
180 pub struct PasswordResetResponse {}
181
182 #[derive(Deserialize)]
183 pub struct PasswordChange {
184   pub token: String,
185   pub password: String,
186   pub password_verify: String,
187 }
188
189 #[derive(Deserialize)]
190 pub struct CreatePrivateMessage {
191   pub content: String,
192   pub recipient_id: PersonId,
193   pub auth: String,
194 }
195
196 #[derive(Deserialize)]
197 pub struct EditPrivateMessage {
198   pub private_message_id: PrivateMessageId,
199   pub content: String,
200   pub auth: String,
201 }
202
203 #[derive(Deserialize)]
204 pub struct DeletePrivateMessage {
205   pub private_message_id: PrivateMessageId,
206   pub deleted: bool,
207   pub auth: String,
208 }
209
210 #[derive(Deserialize)]
211 pub struct MarkPrivateMessageAsRead {
212   pub private_message_id: PrivateMessageId,
213   pub read: bool,
214   pub auth: String,
215 }
216
217 #[derive(Deserialize)]
218 pub struct GetPrivateMessages {
219   pub unread_only: bool,
220   pub page: Option<i64>,
221   pub limit: Option<i64>,
222   pub auth: String,
223 }
224
225 #[derive(Serialize, Clone)]
226 pub struct PrivateMessagesResponse {
227   pub private_messages: Vec<PrivateMessageView>,
228 }
229
230 #[derive(Serialize, Clone)]
231 pub struct PrivateMessageResponse {
232   pub private_message_view: PrivateMessageView,
233 }
234
235 #[derive(Serialize, Deserialize, Debug)]
236 pub struct GetReportCount {
237   pub community: Option<CommunityId>,
238   pub auth: String,
239 }
240
241 #[derive(Serialize, Deserialize, Clone, Debug)]
242 pub struct GetReportCountResponse {
243   pub community: Option<CommunityId>,
244   pub comment_reports: i64,
245   pub post_reports: i64,
246 }