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,
288 #[skip_serializing_none]
289 #[derive(Debug, Serialize, Deserialize, Clone)]
290 #[cfg_attr(feature = "full", derive(TS))]
291 #[cfg_attr(feature = "full", ts(export))]
292 /// An expanded response for a site.
293 pub struct GetSiteResponse {
294 pub site_view: SiteView,
295 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 #[derive(Debug, Serialize, Deserialize, Clone)]
308 #[cfg_attr(feature = "full", derive(TS))]
309 #[cfg_attr(feature = "full", ts(export))]
310 /// Fetches the federated instances for your site.
311 pub struct GetFederatedInstances {}
313 #[skip_serializing_none]
314 #[derive(Debug, Serialize, Deserialize, Clone)]
315 #[cfg_attr(feature = "full", derive(TS))]
316 #[cfg_attr(feature = "full", ts(export))]
317 /// A response of federated instances.
318 pub struct GetFederatedInstancesResponse {
319 /// Optional, because federation may be disabled.
320 pub federated_instances: Option<FederatedInstances>,
323 #[derive(Debug, Serialize, Deserialize, Clone)]
324 #[cfg_attr(feature = "full", derive(TS))]
325 #[cfg_attr(feature = "full", ts(export))]
327 pub struct MyUserInfo {
328 pub local_user_view: LocalUserView,
329 pub follows: Vec<CommunityFollowerView>,
330 pub moderates: Vec<CommunityModeratorView>,
331 pub community_blocks: Vec<CommunityBlockView>,
332 pub person_blocks: Vec<PersonBlockView>,
333 pub discussion_languages: Vec<LanguageId>,
336 #[derive(Debug, Serialize, Deserialize, Clone)]
337 #[cfg_attr(feature = "full", derive(TS))]
338 #[cfg_attr(feature = "full", ts(export))]
339 /// Leaves the admin team.
340 pub struct LeaveAdmin {
341 pub auth: Sensitive<String>,
344 #[derive(Debug, Serialize, Deserialize, Clone)]
345 #[cfg_attr(feature = "full", derive(TS))]
346 #[cfg_attr(feature = "full", ts(export))]
347 /// A list of federated instances.
348 pub struct FederatedInstances {
349 pub linked: Vec<Instance>,
350 pub allowed: Vec<Instance>,
351 pub blocked: Vec<Instance>,
354 #[skip_serializing_none]
355 #[derive(Debug, Serialize, Deserialize, Clone)]
356 #[cfg_attr(feature = "full", derive(TS))]
357 #[cfg_attr(feature = "full", ts(export))]
358 /// Purges a person from the database. This will delete all content attached to that person.
359 pub struct PurgePerson {
360 pub person_id: PersonId,
361 pub reason: Option<String>,
362 pub auth: Sensitive<String>,
365 #[skip_serializing_none]
366 #[derive(Debug, Serialize, Deserialize, Clone)]
367 #[cfg_attr(feature = "full", derive(TS))]
368 #[cfg_attr(feature = "full", ts(export))]
369 /// Purges a community from the database. This will delete all content attached to that community.
370 pub struct PurgeCommunity {
371 pub community_id: CommunityId,
372 pub reason: Option<String>,
373 pub auth: Sensitive<String>,
376 #[skip_serializing_none]
377 #[derive(Debug, Serialize, Deserialize, Clone)]
378 #[cfg_attr(feature = "full", derive(TS))]
379 #[cfg_attr(feature = "full", ts(export))]
380 /// Purges a post from the database. This will delete all content attached to that post.
381 pub struct PurgePost {
383 pub reason: Option<String>,
384 pub auth: Sensitive<String>,
387 #[skip_serializing_none]
388 #[derive(Debug, Serialize, Deserialize, Clone)]
389 #[cfg_attr(feature = "full", derive(TS))]
390 #[cfg_attr(feature = "full", ts(export))]
391 /// Purges a comment from the database. This will delete all content attached to that comment.
392 pub struct PurgeComment {
393 pub comment_id: CommentId,
394 pub reason: Option<String>,
395 pub auth: Sensitive<String>,
398 #[derive(Serialize, Deserialize)]
399 #[cfg_attr(feature = "full", derive(TS))]
400 #[cfg_attr(feature = "full", ts(export))]
401 /// The response for purged items.
402 pub struct PurgeItemResponse {
406 #[skip_serializing_none]
407 #[derive(Debug, Serialize, Deserialize, Clone, Default)]
408 #[cfg_attr(feature = "full", derive(TS))]
409 #[cfg_attr(feature = "full", ts(export))]
410 /// Fetches a list of registration applications.
411 pub struct ListRegistrationApplications {
412 /// Only shows the unread applications (IE those without an admin actor)
413 pub unread_only: Option<bool>,
414 pub page: Option<i64>,
415 pub limit: Option<i64>,
416 pub auth: Sensitive<String>,
419 #[derive(Debug, Serialize, Deserialize, Clone)]
420 #[cfg_attr(feature = "full", derive(TS))]
421 #[cfg_attr(feature = "full", ts(export))]
422 /// The list of registration applications.
423 pub struct ListRegistrationApplicationsResponse {
424 pub registration_applications: Vec<RegistrationApplicationView>,
427 #[skip_serializing_none]
428 #[derive(Debug, Serialize, Deserialize, Clone, Default)]
429 #[cfg_attr(feature = "full", derive(TS))]
430 #[cfg_attr(feature = "full", ts(export))]
431 /// Approves a registration application.
432 pub struct ApproveRegistrationApplication {
435 pub deny_reason: Option<String>,
436 pub auth: Sensitive<String>,
439 #[derive(Debug, Serialize, Deserialize, Clone)]
440 #[cfg_attr(feature = "full", derive(TS))]
441 #[cfg_attr(feature = "full", ts(export))]
442 /// The response of an action done to a registration application.
443 pub struct RegistrationApplicationResponse {
444 pub registration_application: RegistrationApplicationView,
447 #[derive(Debug, Serialize, Deserialize, Clone)]
448 #[cfg_attr(feature = "full", derive(TS))]
449 #[cfg_attr(feature = "full", ts(export))]
450 /// Gets a count of unread registration applications.
451 pub struct GetUnreadRegistrationApplicationCount {
452 pub auth: Sensitive<String>,
455 #[derive(Debug, Serialize, Deserialize, Clone)]
456 #[cfg_attr(feature = "full", derive(TS))]
457 #[cfg_attr(feature = "full", ts(export))]
458 /// The count of unread registration applications.
459 pub struct GetUnreadRegistrationApplicationCountResponse {
460 pub registration_applications: i64,