1 use crate::sensitive::Sensitive;
3 newtypes::{CommentId, CommunityId, LanguageId, PersonId, PostId},
7 local_site::RegistrationMode,
15 use lemmy_db_views::structs::{
20 RegistrationApplicationView,
23 use lemmy_db_views_actor::structs::{
25 CommunityFollowerView,
26 CommunityModeratorView,
31 use lemmy_db_views_moderator::structs::{
32 AdminPurgeCommentView,
33 AdminPurgeCommunityView,
38 ModBanFromCommunityView,
44 ModRemoveCommunityView,
46 ModTransferCommunityView,
48 use serde::{Deserialize, Serialize};
50 #[derive(Debug, Serialize, Deserialize, Clone, Default)]
53 pub community_id: Option<CommunityId>,
54 pub community_name: Option<String>,
55 pub creator_id: Option<PersonId>,
56 pub type_: Option<SearchType>,
57 pub sort: Option<SortType>,
58 pub listing_type: Option<ListingType>,
59 pub page: Option<i64>,
60 pub limit: Option<i64>,
61 pub auth: Option<Sensitive<String>>,
64 #[derive(Debug, Serialize, Deserialize, Clone)]
65 pub struct SearchResponse {
67 pub comments: Vec<CommentView>,
68 pub posts: Vec<PostView>,
69 pub communities: Vec<CommunityView>,
70 pub users: Vec<PersonView>,
73 #[derive(Debug, Serialize, Deserialize, Clone, Default)]
74 pub struct ResolveObject {
76 pub auth: Sensitive<String>,
79 #[derive(Debug, Serialize, Deserialize, Default)]
80 pub struct ResolveObjectResponse {
81 pub comment: Option<CommentView>,
82 pub post: Option<PostView>,
83 pub community: Option<CommunityView>,
84 pub person: Option<PersonView>,
87 #[derive(Debug, Serialize, Deserialize, Clone, Default)]
88 pub struct GetModlog {
89 pub mod_person_id: Option<PersonId>,
90 pub community_id: Option<CommunityId>,
91 pub page: Option<i64>,
92 pub limit: Option<i64>,
93 pub auth: Option<Sensitive<String>>,
94 pub type_: Option<ModlogActionType>,
95 pub other_person_id: Option<PersonId>,
98 #[derive(Debug, Serialize, Deserialize, Clone)]
99 pub struct GetModlogResponse {
100 pub removed_posts: Vec<ModRemovePostView>,
101 pub locked_posts: Vec<ModLockPostView>,
102 pub featured_posts: Vec<ModFeaturePostView>,
103 pub removed_comments: Vec<ModRemoveCommentView>,
104 pub removed_communities: Vec<ModRemoveCommunityView>,
105 pub banned_from_community: Vec<ModBanFromCommunityView>,
106 pub banned: Vec<ModBanView>,
107 pub added_to_community: Vec<ModAddCommunityView>,
108 pub transferred_to_community: Vec<ModTransferCommunityView>,
109 pub added: Vec<ModAddView>,
110 pub admin_purged_persons: Vec<AdminPurgePersonView>,
111 pub admin_purged_communities: Vec<AdminPurgeCommunityView>,
112 pub admin_purged_posts: Vec<AdminPurgePostView>,
113 pub admin_purged_comments: Vec<AdminPurgeCommentView>,
114 pub hidden_communities: Vec<ModHideCommunityView>,
117 #[derive(Debug, Serialize, Deserialize, Clone, Default)]
118 pub struct CreateSite {
120 pub sidebar: Option<String>,
121 pub description: Option<String>,
122 pub icon: Option<String>,
123 pub banner: Option<String>,
124 pub enable_downvotes: Option<bool>,
125 pub enable_nsfw: Option<bool>,
126 pub community_creation_admin_only: Option<bool>,
127 pub require_email_verification: Option<bool>,
128 pub application_question: Option<String>,
129 pub private_instance: Option<bool>,
130 pub default_theme: Option<String>,
131 pub default_post_listing_type: Option<String>,
132 pub legal_information: Option<String>,
133 pub application_email_admins: Option<bool>,
134 pub hide_modlog_mod_names: Option<bool>,
135 pub discussion_languages: Option<Vec<LanguageId>>,
136 pub slur_filter_regex: Option<String>,
137 pub actor_name_max_length: Option<i32>,
138 pub rate_limit_message: Option<i32>,
139 pub rate_limit_message_per_second: Option<i32>,
140 pub rate_limit_post: Option<i32>,
141 pub rate_limit_post_per_second: Option<i32>,
142 pub rate_limit_register: Option<i32>,
143 pub rate_limit_register_per_second: Option<i32>,
144 pub rate_limit_image: Option<i32>,
145 pub rate_limit_image_per_second: Option<i32>,
146 pub rate_limit_comment: Option<i32>,
147 pub rate_limit_comment_per_second: Option<i32>,
148 pub rate_limit_search: Option<i32>,
149 pub rate_limit_search_per_second: Option<i32>,
150 pub federation_enabled: Option<bool>,
151 pub federation_debug: Option<bool>,
152 pub federation_worker_count: Option<i32>,
153 pub captcha_enabled: Option<bool>,
154 pub captcha_difficulty: Option<String>,
155 pub allowed_instances: Option<Vec<String>>,
156 pub blocked_instances: Option<Vec<String>>,
157 pub taglines: Option<Vec<String>>,
158 pub registration_mode: Option<RegistrationMode>,
159 pub auth: Sensitive<String>,
162 #[derive(Debug, Serialize, Deserialize, Clone, Default)]
163 pub struct EditSite {
164 pub name: Option<String>,
165 pub sidebar: Option<String>,
166 pub description: Option<String>,
167 pub icon: Option<String>,
168 pub banner: Option<String>,
169 pub enable_downvotes: Option<bool>,
170 pub enable_nsfw: Option<bool>,
171 pub community_creation_admin_only: Option<bool>,
172 pub require_email_verification: Option<bool>,
173 pub application_question: Option<String>,
174 pub private_instance: Option<bool>,
175 pub default_theme: Option<String>,
176 pub default_post_listing_type: Option<String>,
177 pub legal_information: Option<String>,
178 pub application_email_admins: Option<bool>,
179 pub hide_modlog_mod_names: Option<bool>,
180 pub discussion_languages: Option<Vec<LanguageId>>,
181 pub slur_filter_regex: Option<String>,
182 pub actor_name_max_length: Option<i32>,
183 pub rate_limit_message: Option<i32>,
184 pub rate_limit_message_per_second: Option<i32>,
185 pub rate_limit_post: Option<i32>,
186 pub rate_limit_post_per_second: Option<i32>,
187 pub rate_limit_register: Option<i32>,
188 pub rate_limit_register_per_second: Option<i32>,
189 pub rate_limit_image: Option<i32>,
190 pub rate_limit_image_per_second: Option<i32>,
191 pub rate_limit_comment: Option<i32>,
192 pub rate_limit_comment_per_second: Option<i32>,
193 pub rate_limit_search: Option<i32>,
194 pub rate_limit_search_per_second: Option<i32>,
195 pub federation_enabled: Option<bool>,
196 pub federation_debug: Option<bool>,
197 pub federation_worker_count: Option<i32>,
198 pub captcha_enabled: Option<bool>,
199 pub captcha_difficulty: Option<String>,
200 pub allowed_instances: Option<Vec<String>>,
201 pub blocked_instances: Option<Vec<String>>,
202 pub taglines: Option<Vec<String>>,
203 pub registration_mode: Option<RegistrationMode>,
204 pub reports_email_admins: Option<bool>,
205 pub auth: Sensitive<String>,
208 #[derive(Debug, Serialize, Deserialize, Clone, Default)]
210 pub auth: Option<Sensitive<String>>,
213 #[derive(Debug, Serialize, Deserialize, Clone)]
214 pub struct SiteResponse {
215 pub site_view: SiteView,
218 #[derive(Debug, Serialize, Deserialize, Clone)]
219 pub struct GetSiteResponse {
220 pub site_view: SiteView,
221 pub admins: Vec<PersonView>,
224 pub my_user: Option<MyUserInfo>,
225 pub all_languages: Vec<Language>,
226 pub discussion_languages: Vec<LanguageId>,
227 pub taglines: Vec<Tagline>,
228 pub custom_emojis: Vec<CustomEmojiView>,
231 #[derive(Debug, Serialize, Deserialize, Clone)]
232 pub struct GetFederatedInstances {}
234 #[derive(Debug, Serialize, Deserialize, Clone)]
235 pub struct GetFederatedInstancesResponse {
236 pub federated_instances: Option<FederatedInstances>, // Federation may be disabled
239 #[derive(Debug, Serialize, Deserialize, Clone)]
240 pub struct MyUserInfo {
241 pub local_user_view: LocalUserView,
242 pub follows: Vec<CommunityFollowerView>,
243 pub moderates: Vec<CommunityModeratorView>,
244 pub community_blocks: Vec<CommunityBlockView>,
245 pub person_blocks: Vec<PersonBlockView>,
246 pub discussion_languages: Vec<LanguageId>,
249 #[derive(Debug, Serialize, Deserialize, Clone)]
250 pub struct LeaveAdmin {
251 pub auth: Sensitive<String>,
254 #[derive(Debug, Serialize, Deserialize, Clone)]
255 pub struct FederatedInstances {
256 pub linked: Vec<Instance>,
257 pub allowed: Option<Vec<Instance>>,
258 pub blocked: Option<Vec<Instance>>,
261 #[derive(Debug, Serialize, Deserialize, Clone)]
262 pub struct PurgePerson {
263 pub person_id: PersonId,
264 pub reason: Option<String>,
268 #[derive(Debug, Serialize, Deserialize, Clone)]
269 pub struct PurgeCommunity {
270 pub community_id: CommunityId,
271 pub reason: Option<String>,
275 #[derive(Debug, Serialize, Deserialize, Clone)]
276 pub struct PurgePost {
278 pub reason: Option<String>,
282 #[derive(Debug, Serialize, Deserialize, Clone)]
283 pub struct PurgeComment {
284 pub comment_id: CommentId,
285 pub reason: Option<String>,
289 #[derive(Serialize, Deserialize)]
290 pub struct PurgeItemResponse {
294 #[derive(Debug, Serialize, Deserialize, Clone, Default)]
295 pub struct ListRegistrationApplications {
296 /// Only shows the unread applications (IE those without an admin actor)
297 pub unread_only: Option<bool>,
298 pub page: Option<i64>,
299 pub limit: Option<i64>,
303 #[derive(Debug, Serialize, Deserialize, Clone)]
304 pub struct ListRegistrationApplicationsResponse {
305 pub registration_applications: Vec<RegistrationApplicationView>,
308 #[derive(Debug, Serialize, Deserialize, Clone, Default)]
309 pub struct ApproveRegistrationApplication {
312 pub deny_reason: Option<String>,
316 #[derive(Debug, Serialize, Deserialize, Clone)]
317 pub struct RegistrationApplicationResponse {
318 pub registration_application: RegistrationApplicationView,
321 #[derive(Debug, Serialize, Deserialize, Clone)]
322 pub struct GetUnreadRegistrationApplicationCount {
326 #[derive(Debug, Serialize, Deserialize, Clone)]
327 pub struct GetUnreadRegistrationApplicationCountResponse {
328 pub registration_applications: i64,