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