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