1 use crate::sensitive::Sensitive;
3 newtypes::{CommentId, CommunityId, LanguageId, PersonId, PostId},
4 source::{instance::Instance, language::Language, tagline::Tagline},
11 use lemmy_db_views::structs::{
16 RegistrationApplicationView,
19 use lemmy_db_views_actor::structs::{
21 CommunityFollowerView,
22 CommunityModeratorView,
27 use lemmy_db_views_moderator::structs::{
28 AdminPurgeCommentView,
29 AdminPurgeCommunityView,
34 ModBanFromCommunityView,
40 ModRemoveCommunityView,
42 ModTransferCommunityView,
44 use serde::{Deserialize, Serialize};
45 use serde_with::skip_serializing_none;
46 #[cfg(feature = "full")]
49 #[skip_serializing_none]
50 #[derive(Debug, Serialize, Deserialize, Clone, Default)]
51 #[cfg_attr(feature = "full", derive(TS))]
52 #[cfg_attr(feature = "full", ts(export))]
53 /// Searches the site, given a query string, and some optional filters.
56 pub community_id: Option<CommunityId>,
57 pub community_name: Option<String>,
58 pub creator_id: Option<PersonId>,
59 pub type_: Option<SearchType>,
60 pub sort: Option<SortType>,
61 pub listing_type: Option<ListingType>,
62 pub page: Option<i64>,
63 pub limit: Option<i64>,
64 pub auth: Option<Sensitive<String>>,
67 #[derive(Debug, Serialize, Deserialize, Clone)]
68 #[cfg_attr(feature = "full", derive(TS))]
69 #[cfg_attr(feature = "full", ts(export))]
70 /// The search response, containing lists of the return type possibilities
71 // TODO this should be redone as a list of tagged enums
72 pub struct SearchResponse {
73 pub type_: SearchType,
74 pub comments: Vec<CommentView>,
75 pub posts: Vec<PostView>,
76 pub communities: Vec<CommunityView>,
77 pub users: Vec<PersonView>,
80 #[derive(Debug, Serialize, Deserialize, Clone, Default)]
81 #[cfg_attr(feature = "full", derive(TS))]
82 #[cfg_attr(feature = "full", ts(export))]
83 /// Does an apub fetch for an object.
84 pub struct ResolveObject {
85 /// Can be the full url, or a shortened version like: !fediverse@lemmy.ml
87 pub auth: Sensitive<String>,
90 #[skip_serializing_none]
91 #[derive(Debug, Serialize, Deserialize, Default)]
92 #[cfg_attr(feature = "full", derive(TS))]
93 #[cfg_attr(feature = "full", ts(export))]
94 // TODO Change this to an enum
95 /// The response of an apub object fetch.
96 pub struct ResolveObjectResponse {
97 pub comment: Option<CommentView>,
98 pub post: Option<PostView>,
99 pub community: Option<CommunityView>,
100 pub person: Option<PersonView>,
103 #[skip_serializing_none]
104 #[derive(Debug, Serialize, Deserialize, Clone, Default)]
105 #[cfg_attr(feature = "full", derive(TS))]
106 #[cfg_attr(feature = "full", ts(export))]
107 /// Fetches the modlog.
108 pub struct GetModlog {
109 pub mod_person_id: Option<PersonId>,
110 pub community_id: Option<CommunityId>,
111 pub page: Option<i64>,
112 pub limit: Option<i64>,
113 pub type_: Option<ModlogActionType>,
114 pub other_person_id: Option<PersonId>,
115 pub auth: Option<Sensitive<String>>,
118 #[derive(Debug, Serialize, Deserialize, Clone)]
119 #[cfg_attr(feature = "full", derive(TS))]
120 #[cfg_attr(feature = "full", ts(export))]
121 /// The modlog fetch response.
122 // TODO this should be redone as a list of tagged enums
123 pub struct GetModlogResponse {
124 pub removed_posts: Vec<ModRemovePostView>,
125 pub locked_posts: Vec<ModLockPostView>,
126 pub featured_posts: Vec<ModFeaturePostView>,
127 pub removed_comments: Vec<ModRemoveCommentView>,
128 pub removed_communities: Vec<ModRemoveCommunityView>,
129 pub banned_from_community: Vec<ModBanFromCommunityView>,
130 pub banned: Vec<ModBanView>,
131 pub added_to_community: Vec<ModAddCommunityView>,
132 pub transferred_to_community: Vec<ModTransferCommunityView>,
133 pub added: Vec<ModAddView>,
134 pub admin_purged_persons: Vec<AdminPurgePersonView>,
135 pub admin_purged_communities: Vec<AdminPurgeCommunityView>,
136 pub admin_purged_posts: Vec<AdminPurgePostView>,
137 pub admin_purged_comments: Vec<AdminPurgeCommentView>,
138 pub hidden_communities: Vec<ModHideCommunityView>,
141 #[skip_serializing_none]
142 #[derive(Debug, Serialize, Deserialize, Clone, Default)]
143 #[cfg_attr(feature = "full", derive(TS))]
144 #[cfg_attr(feature = "full", ts(export))]
145 /// Creates a site. Should be done after first running lemmy.
146 pub struct CreateSite {
148 pub sidebar: Option<String>,
149 pub description: Option<String>,
150 pub icon: Option<String>,
151 pub banner: Option<String>,
152 pub enable_downvotes: Option<bool>,
153 pub enable_nsfw: Option<bool>,
154 pub community_creation_admin_only: Option<bool>,
155 pub require_email_verification: Option<bool>,
156 pub application_question: Option<String>,
157 pub private_instance: Option<bool>,
158 pub default_theme: Option<String>,
159 pub default_post_listing_type: Option<ListingType>,
160 pub legal_information: Option<String>,
161 pub application_email_admins: Option<bool>,
162 pub hide_modlog_mod_names: Option<bool>,
163 pub discussion_languages: Option<Vec<LanguageId>>,
164 pub slur_filter_regex: Option<String>,
165 pub actor_name_max_length: Option<i32>,
166 pub rate_limit_message: Option<i32>,
167 pub rate_limit_message_per_second: Option<i32>,
168 pub rate_limit_post: Option<i32>,
169 pub rate_limit_post_per_second: Option<i32>,
170 pub rate_limit_register: Option<i32>,
171 pub rate_limit_register_per_second: Option<i32>,
172 pub rate_limit_image: Option<i32>,
173 pub rate_limit_image_per_second: Option<i32>,
174 pub rate_limit_comment: Option<i32>,
175 pub rate_limit_comment_per_second: Option<i32>,
176 pub rate_limit_search: Option<i32>,
177 pub rate_limit_search_per_second: Option<i32>,
178 pub federation_enabled: Option<bool>,
179 pub federation_debug: Option<bool>,
180 pub federation_worker_count: Option<i32>,
181 pub captcha_enabled: Option<bool>,
182 pub captcha_difficulty: Option<String>,
183 pub allowed_instances: Option<Vec<String>>,
184 pub blocked_instances: Option<Vec<String>>,
185 pub taglines: Option<Vec<String>>,
186 pub registration_mode: Option<RegistrationMode>,
187 pub auth: Sensitive<String>,
190 #[skip_serializing_none]
191 #[derive(Debug, Serialize, Deserialize, Clone, Default)]
192 #[cfg_attr(feature = "full", derive(TS))]
193 #[cfg_attr(feature = "full", ts(export))]
195 pub struct EditSite {
196 pub name: Option<String>,
197 pub sidebar: Option<String>,
198 /// A shorter, one line description of your site.
199 pub description: Option<String>,
200 /// A url for your site's icon.
201 pub icon: Option<String>,
202 /// A url for your site's banner.
203 pub banner: Option<String>,
204 /// Whether to enable downvotes.
205 pub enable_downvotes: Option<bool>,
206 /// Whether to enable NSFW.
207 pub enable_nsfw: Option<bool>,
208 /// Limits community creation to admins only.
209 pub community_creation_admin_only: Option<bool>,
210 /// Whether to require email verification.
211 pub require_email_verification: Option<bool>,
212 /// Your application question form. This is in markdown, and can be many questions.
213 pub application_question: Option<String>,
214 /// Whether your instance is public, or private.
215 pub private_instance: Option<bool>,
216 /// The default theme. Usually "browser"
217 pub default_theme: Option<String>,
218 pub default_post_listing_type: Option<ListingType>,
219 /// An optional page of legal information
220 pub legal_information: Option<String>,
221 /// Whether to email admins when receiving a new application.
222 pub application_email_admins: Option<bool>,
223 /// Whether to hide moderator names from the modlog.
224 pub hide_modlog_mod_names: Option<bool>,
225 /// A list of allowed discussion languages.
226 pub discussion_languages: Option<Vec<LanguageId>>,
227 /// A regex string of items to filter.
228 pub slur_filter_regex: Option<String>,
229 /// The max length of actor names.
230 pub actor_name_max_length: Option<i32>,
231 /// The number of messages allowed in a given time frame.
232 pub rate_limit_message: Option<i32>,
233 pub rate_limit_message_per_second: Option<i32>,
234 /// The number of posts allowed in a given time frame.
235 pub rate_limit_post: Option<i32>,
236 pub rate_limit_post_per_second: Option<i32>,
237 /// The number of registrations allowed in a given time frame.
238 pub rate_limit_register: Option<i32>,
239 pub rate_limit_register_per_second: Option<i32>,
240 /// The number of image uploads allowed in a given time frame.
241 pub rate_limit_image: Option<i32>,
242 pub rate_limit_image_per_second: Option<i32>,
243 /// The number of comments allowed in a given time frame.
244 pub rate_limit_comment: Option<i32>,
245 pub rate_limit_comment_per_second: Option<i32>,
246 /// The number of searches allowed in a given time frame.
247 pub rate_limit_search: Option<i32>,
248 pub rate_limit_search_per_second: Option<i32>,
249 /// Whether to enable federation.
250 pub federation_enabled: Option<bool>,
251 /// Enables federation debugging.
252 pub federation_debug: Option<bool>,
253 /// The number of federation workers.
254 pub federation_worker_count: Option<i32>,
255 /// Whether to enable captchas for signups.
256 pub captcha_enabled: Option<bool>,
257 /// The captcha difficulty. Can be easy, medium, or hard
258 pub captcha_difficulty: Option<String>,
259 /// A list of allowed instances. If none are set, federation is open.
260 pub allowed_instances: Option<Vec<String>>,
261 /// A list of blocked instances.
262 pub blocked_instances: Option<Vec<String>>,
263 /// A list of taglines shown at the top of the front page.
264 pub taglines: Option<Vec<String>>,
265 pub registration_mode: Option<RegistrationMode>,
266 /// Whether to email admins for new reports.
267 pub reports_email_admins: Option<bool>,
268 pub auth: Sensitive<String>,
271 #[skip_serializing_none]
272 #[derive(Debug, Serialize, Deserialize, Clone, Default)]
273 #[cfg_attr(feature = "full", derive(TS))]
274 #[cfg_attr(feature = "full", ts(export))]
275 /// Fetches the site.
277 pub auth: Option<Sensitive<String>>,
280 #[derive(Debug, Serialize, Deserialize, Clone)]
281 #[cfg_attr(feature = "full", derive(TS))]
282 #[cfg_attr(feature = "full", ts(export))]
283 /// The response for a site.
284 pub struct SiteResponse {
285 pub site_view: SiteView,
286 pub taglines: Vec<Tagline>,
289 #[skip_serializing_none]
290 #[derive(Debug, Serialize, Deserialize, Clone)]
291 #[cfg_attr(feature = "full", derive(TS))]
292 #[cfg_attr(feature = "full", ts(export))]
293 /// An expanded response for a site.
294 pub struct GetSiteResponse {
295 pub site_view: SiteView,
296 pub admins: Vec<PersonView>,
298 pub my_user: Option<MyUserInfo>,
299 pub all_languages: Vec<Language>,
300 pub discussion_languages: Vec<LanguageId>,
301 /// A list of taglines shown at the top of the front page.
302 pub taglines: Vec<Tagline>,
303 /// A list of custom emojis your site supports.
304 pub custom_emojis: Vec<CustomEmojiView>,
307 #[skip_serializing_none]
308 #[derive(Debug, Serialize, Deserialize, Clone)]
309 #[cfg_attr(feature = "full", derive(TS))]
310 #[cfg_attr(feature = "full", ts(export))]
311 /// Fetches the federated instances for your site.
312 pub struct GetFederatedInstances {
313 pub auth: Option<Sensitive<String>>,
316 #[skip_serializing_none]
317 #[derive(Debug, Serialize, Deserialize, Clone)]
318 #[cfg_attr(feature = "full", derive(TS))]
319 #[cfg_attr(feature = "full", ts(export))]
320 /// A response of federated instances.
321 pub struct GetFederatedInstancesResponse {
322 /// Optional, because federation may be disabled.
323 pub federated_instances: Option<FederatedInstances>,
326 #[derive(Debug, Serialize, Deserialize, Clone)]
327 #[cfg_attr(feature = "full", derive(TS))]
328 #[cfg_attr(feature = "full", ts(export))]
330 pub struct MyUserInfo {
331 pub local_user_view: LocalUserView,
332 pub follows: Vec<CommunityFollowerView>,
333 pub moderates: Vec<CommunityModeratorView>,
334 pub community_blocks: Vec<CommunityBlockView>,
335 pub person_blocks: Vec<PersonBlockView>,
336 pub discussion_languages: Vec<LanguageId>,
339 #[derive(Debug, Serialize, Deserialize, Clone)]
340 #[cfg_attr(feature = "full", derive(TS))]
341 #[cfg_attr(feature = "full", ts(export))]
342 /// Leaves the admin team.
343 pub struct LeaveAdmin {
344 pub auth: Sensitive<String>,
347 #[derive(Debug, Serialize, Deserialize, Clone)]
348 #[cfg_attr(feature = "full", derive(TS))]
349 #[cfg_attr(feature = "full", ts(export))]
350 /// A list of federated instances.
351 pub struct FederatedInstances {
352 pub linked: Vec<Instance>,
353 pub allowed: Vec<Instance>,
354 pub blocked: Vec<Instance>,
357 #[skip_serializing_none]
358 #[derive(Debug, Serialize, Deserialize, Clone)]
359 #[cfg_attr(feature = "full", derive(TS))]
360 #[cfg_attr(feature = "full", ts(export))]
361 /// Purges a person from the database. This will delete all content attached to that person.
362 pub struct PurgePerson {
363 pub person_id: PersonId,
364 pub reason: Option<String>,
365 pub auth: Sensitive<String>,
368 #[skip_serializing_none]
369 #[derive(Debug, Serialize, Deserialize, Clone)]
370 #[cfg_attr(feature = "full", derive(TS))]
371 #[cfg_attr(feature = "full", ts(export))]
372 /// Purges a community from the database. This will delete all content attached to that community.
373 pub struct PurgeCommunity {
374 pub community_id: CommunityId,
375 pub reason: Option<String>,
376 pub auth: Sensitive<String>,
379 #[skip_serializing_none]
380 #[derive(Debug, Serialize, Deserialize, Clone)]
381 #[cfg_attr(feature = "full", derive(TS))]
382 #[cfg_attr(feature = "full", ts(export))]
383 /// Purges a post from the database. This will delete all content attached to that post.
384 pub struct PurgePost {
386 pub reason: Option<String>,
387 pub auth: Sensitive<String>,
390 #[skip_serializing_none]
391 #[derive(Debug, Serialize, Deserialize, Clone)]
392 #[cfg_attr(feature = "full", derive(TS))]
393 #[cfg_attr(feature = "full", ts(export))]
394 /// Purges a comment from the database. This will delete all content attached to that comment.
395 pub struct PurgeComment {
396 pub comment_id: CommentId,
397 pub reason: Option<String>,
398 pub auth: Sensitive<String>,
401 #[derive(Serialize, Deserialize)]
402 #[cfg_attr(feature = "full", derive(TS))]
403 #[cfg_attr(feature = "full", ts(export))]
404 /// The response for purged items.
405 pub struct PurgeItemResponse {
409 #[skip_serializing_none]
410 #[derive(Debug, Serialize, Deserialize, Clone, Default)]
411 #[cfg_attr(feature = "full", derive(TS))]
412 #[cfg_attr(feature = "full", ts(export))]
413 /// Fetches a list of registration applications.
414 pub struct ListRegistrationApplications {
415 /// Only shows the unread applications (IE those without an admin actor)
416 pub unread_only: Option<bool>,
417 pub page: Option<i64>,
418 pub limit: Option<i64>,
419 pub auth: Sensitive<String>,
422 #[derive(Debug, Serialize, Deserialize, Clone)]
423 #[cfg_attr(feature = "full", derive(TS))]
424 #[cfg_attr(feature = "full", ts(export))]
425 /// The list of registration applications.
426 pub struct ListRegistrationApplicationsResponse {
427 pub registration_applications: Vec<RegistrationApplicationView>,
430 #[skip_serializing_none]
431 #[derive(Debug, Serialize, Deserialize, Clone, Default)]
432 #[cfg_attr(feature = "full", derive(TS))]
433 #[cfg_attr(feature = "full", ts(export))]
434 /// Approves a registration application.
435 pub struct ApproveRegistrationApplication {
438 pub deny_reason: Option<String>,
439 pub auth: Sensitive<String>,
442 #[derive(Debug, Serialize, Deserialize, Clone)]
443 #[cfg_attr(feature = "full", derive(TS))]
444 #[cfg_attr(feature = "full", ts(export))]
445 /// The response of an action done to a registration application.
446 pub struct RegistrationApplicationResponse {
447 pub registration_application: RegistrationApplicationView,
450 #[derive(Debug, Serialize, Deserialize, Clone)]
451 #[cfg_attr(feature = "full", derive(TS))]
452 #[cfg_attr(feature = "full", ts(export))]
453 /// Gets a count of unread registration applications.
454 pub struct GetUnreadRegistrationApplicationCount {
455 pub auth: Sensitive<String>,
458 #[derive(Debug, Serialize, Deserialize, Clone)]
459 #[cfg_attr(feature = "full", derive(TS))]
460 #[cfg_attr(feature = "full", ts(export))]
461 /// The count of unread registration applications.
462 pub struct GetUnreadRegistrationApplicationCountResponse {
463 pub registration_applications: i64,