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};
46 #[derive(Debug, Serialize, Deserialize, Clone, Default)]
49 pub community_id: Option<CommunityId>,
50 pub community_name: Option<String>,
51 pub creator_id: Option<PersonId>,
52 pub type_: Option<SearchType>,
53 pub sort: Option<SortType>,
54 pub listing_type: Option<ListingType>,
55 pub page: Option<i64>,
56 pub limit: Option<i64>,
57 pub auth: Option<Sensitive<String>>,
60 #[derive(Debug, Serialize, Deserialize, Clone)]
61 pub struct SearchResponse {
63 pub comments: Vec<CommentView>,
64 pub posts: Vec<PostView>,
65 pub communities: Vec<CommunityView>,
66 pub users: Vec<PersonView>,
69 #[derive(Debug, Serialize, Deserialize, Clone, Default)]
70 pub struct ResolveObject {
72 pub auth: Sensitive<String>,
75 #[derive(Debug, Serialize, Deserialize, Default)]
76 pub struct ResolveObjectResponse {
77 pub comment: Option<CommentView>,
78 pub post: Option<PostView>,
79 pub community: Option<CommunityView>,
80 pub person: Option<PersonView>,
83 #[derive(Debug, Serialize, Deserialize, Clone, Default)]
84 pub struct GetModlog {
85 pub mod_person_id: Option<PersonId>,
86 pub community_id: Option<CommunityId>,
87 pub page: Option<i64>,
88 pub limit: Option<i64>,
89 pub auth: Option<Sensitive<String>>,
90 pub type_: Option<ModlogActionType>,
91 pub other_person_id: Option<PersonId>,
94 #[derive(Debug, Serialize, Deserialize, Clone)]
95 pub struct GetModlogResponse {
96 pub removed_posts: Vec<ModRemovePostView>,
97 pub locked_posts: Vec<ModLockPostView>,
98 pub featured_posts: Vec<ModFeaturePostView>,
99 pub removed_comments: Vec<ModRemoveCommentView>,
100 pub removed_communities: Vec<ModRemoveCommunityView>,
101 pub banned_from_community: Vec<ModBanFromCommunityView>,
102 pub banned: Vec<ModBanView>,
103 pub added_to_community: Vec<ModAddCommunityView>,
104 pub transferred_to_community: Vec<ModTransferCommunityView>,
105 pub added: Vec<ModAddView>,
106 pub admin_purged_persons: Vec<AdminPurgePersonView>,
107 pub admin_purged_communities: Vec<AdminPurgeCommunityView>,
108 pub admin_purged_posts: Vec<AdminPurgePostView>,
109 pub admin_purged_comments: Vec<AdminPurgeCommentView>,
110 pub hidden_communities: Vec<ModHideCommunityView>,
113 #[derive(Debug, Serialize, Deserialize, Clone, Default)]
114 pub struct CreateSite {
116 pub sidebar: Option<String>,
117 pub description: Option<String>,
118 pub icon: Option<String>,
119 pub banner: Option<String>,
120 pub enable_downvotes: Option<bool>,
121 pub enable_nsfw: Option<bool>,
122 pub community_creation_admin_only: Option<bool>,
123 pub require_email_verification: Option<bool>,
124 pub application_question: Option<String>,
125 pub private_instance: Option<bool>,
126 pub default_theme: Option<String>,
127 pub default_post_listing_type: Option<ListingType>,
128 pub legal_information: Option<String>,
129 pub application_email_admins: Option<bool>,
130 pub hide_modlog_mod_names: Option<bool>,
131 pub discussion_languages: Option<Vec<LanguageId>>,
132 pub slur_filter_regex: Option<String>,
133 pub actor_name_max_length: Option<i32>,
134 pub rate_limit_message: Option<i32>,
135 pub rate_limit_message_per_second: Option<i32>,
136 pub rate_limit_post: Option<i32>,
137 pub rate_limit_post_per_second: Option<i32>,
138 pub rate_limit_register: Option<i32>,
139 pub rate_limit_register_per_second: Option<i32>,
140 pub rate_limit_image: Option<i32>,
141 pub rate_limit_image_per_second: Option<i32>,
142 pub rate_limit_comment: Option<i32>,
143 pub rate_limit_comment_per_second: Option<i32>,
144 pub rate_limit_search: Option<i32>,
145 pub rate_limit_search_per_second: Option<i32>,
146 pub federation_enabled: Option<bool>,
147 pub federation_debug: Option<bool>,
148 pub federation_worker_count: Option<i32>,
149 pub captcha_enabled: Option<bool>,
150 pub captcha_difficulty: Option<String>,
151 pub allowed_instances: Option<Vec<String>>,
152 pub blocked_instances: Option<Vec<String>>,
153 pub taglines: Option<Vec<String>>,
154 pub registration_mode: Option<RegistrationMode>,
155 pub auth: Sensitive<String>,
158 #[derive(Debug, Serialize, Deserialize, Clone, Default)]
159 pub struct EditSite {
160 pub name: Option<String>,
161 pub sidebar: Option<String>,
162 pub description: Option<String>,
163 pub icon: Option<String>,
164 pub banner: Option<String>,
165 pub enable_downvotes: Option<bool>,
166 pub enable_nsfw: Option<bool>,
167 pub community_creation_admin_only: Option<bool>,
168 pub require_email_verification: Option<bool>,
169 pub application_question: Option<String>,
170 pub private_instance: Option<bool>,
171 pub default_theme: Option<String>,
172 pub default_post_listing_type: Option<ListingType>,
173 pub legal_information: Option<String>,
174 pub application_email_admins: Option<bool>,
175 pub hide_modlog_mod_names: Option<bool>,
176 pub discussion_languages: Option<Vec<LanguageId>>,
177 pub slur_filter_regex: Option<String>,
178 pub actor_name_max_length: Option<i32>,
179 pub rate_limit_message: Option<i32>,
180 pub rate_limit_message_per_second: Option<i32>,
181 pub rate_limit_post: Option<i32>,
182 pub rate_limit_post_per_second: Option<i32>,
183 pub rate_limit_register: Option<i32>,
184 pub rate_limit_register_per_second: Option<i32>,
185 pub rate_limit_image: Option<i32>,
186 pub rate_limit_image_per_second: Option<i32>,
187 pub rate_limit_comment: Option<i32>,
188 pub rate_limit_comment_per_second: Option<i32>,
189 pub rate_limit_search: Option<i32>,
190 pub rate_limit_search_per_second: Option<i32>,
191 pub federation_enabled: Option<bool>,
192 pub federation_debug: Option<bool>,
193 pub federation_worker_count: Option<i32>,
194 pub captcha_enabled: Option<bool>,
195 pub captcha_difficulty: Option<String>,
196 pub allowed_instances: Option<Vec<String>>,
197 pub blocked_instances: Option<Vec<String>>,
198 pub taglines: Option<Vec<String>>,
199 pub registration_mode: Option<RegistrationMode>,
200 pub reports_email_admins: Option<bool>,
201 pub auth: Sensitive<String>,
204 #[derive(Debug, Serialize, Deserialize, Clone, Default)]
206 pub auth: Option<Sensitive<String>>,
209 #[derive(Debug, Serialize, Deserialize, Clone)]
210 pub struct SiteResponse {
211 pub site_view: SiteView,
214 #[derive(Debug, Serialize, Deserialize, Clone)]
215 pub struct GetSiteResponse {
216 pub site_view: SiteView,
217 pub admins: Vec<PersonView>,
220 pub my_user: Option<MyUserInfo>,
221 pub all_languages: Vec<Language>,
222 pub discussion_languages: Vec<LanguageId>,
223 pub taglines: Vec<Tagline>,
224 pub custom_emojis: Vec<CustomEmojiView>,
227 #[derive(Debug, Serialize, Deserialize, Clone)]
228 pub struct GetFederatedInstances {}
230 #[derive(Debug, Serialize, Deserialize, Clone)]
231 pub struct GetFederatedInstancesResponse {
232 pub federated_instances: Option<FederatedInstances>, // Federation may be disabled
235 #[derive(Debug, Serialize, Deserialize, Clone)]
236 pub struct MyUserInfo {
237 pub local_user_view: LocalUserView,
238 pub follows: Vec<CommunityFollowerView>,
239 pub moderates: Vec<CommunityModeratorView>,
240 pub community_blocks: Vec<CommunityBlockView>,
241 pub person_blocks: Vec<PersonBlockView>,
242 pub discussion_languages: Vec<LanguageId>,
245 #[derive(Debug, Serialize, Deserialize, Clone)]
246 pub struct LeaveAdmin {
247 pub auth: Sensitive<String>,
250 #[derive(Debug, Serialize, Deserialize, Clone)]
251 pub struct FederatedInstances {
252 pub linked: Vec<Instance>,
253 pub allowed: Option<Vec<Instance>>,
254 pub blocked: Option<Vec<Instance>>,
257 #[derive(Debug, Serialize, Deserialize, Clone)]
258 pub struct PurgePerson {
259 pub person_id: PersonId,
260 pub reason: Option<String>,
264 #[derive(Debug, Serialize, Deserialize, Clone)]
265 pub struct PurgeCommunity {
266 pub community_id: CommunityId,
267 pub reason: Option<String>,
271 #[derive(Debug, Serialize, Deserialize, Clone)]
272 pub struct PurgePost {
274 pub reason: Option<String>,
278 #[derive(Debug, Serialize, Deserialize, Clone)]
279 pub struct PurgeComment {
280 pub comment_id: CommentId,
281 pub reason: Option<String>,
285 #[derive(Serialize, Deserialize)]
286 pub struct PurgeItemResponse {
290 #[derive(Debug, Serialize, Deserialize, Clone, Default)]
291 pub struct ListRegistrationApplications {
292 /// Only shows the unread applications (IE those without an admin actor)
293 pub unread_only: Option<bool>,
294 pub page: Option<i64>,
295 pub limit: Option<i64>,
299 #[derive(Debug, Serialize, Deserialize, Clone)]
300 pub struct ListRegistrationApplicationsResponse {
301 pub registration_applications: Vec<RegistrationApplicationView>,
304 #[derive(Debug, Serialize, Deserialize, Clone, Default)]
305 pub struct ApproveRegistrationApplication {
308 pub deny_reason: Option<String>,
312 #[derive(Debug, Serialize, Deserialize, Clone)]
313 pub struct RegistrationApplicationResponse {
314 pub registration_application: RegistrationApplicationView,
317 #[derive(Debug, Serialize, Deserialize, Clone)]
318 pub struct GetUnreadRegistrationApplicationCount {
322 #[derive(Debug, Serialize, Deserialize, Clone)]
323 pub struct GetUnreadRegistrationApplicationCountResponse {
324 pub registration_applications: i64,