1 use crate::sensitive::Sensitive;
3 newtypes::{CommentId, CommunityId, LanguageId, PersonId, PostId},
4 source::{language::Language, tagline::Tagline},
10 use lemmy_db_views::structs::{
12 LocalUserSettingsView,
14 RegistrationApplicationView,
17 use lemmy_db_views_actor::structs::{
19 CommunityFollowerView,
20 CommunityModeratorView,
25 use lemmy_db_views_moderator::structs::{
26 AdminPurgeCommentView,
27 AdminPurgeCommunityView,
32 ModBanFromCommunityView,
38 ModRemoveCommunityView,
40 ModTransferCommunityView,
42 use serde::{Deserialize, Serialize};
44 #[derive(Debug, Serialize, Deserialize, Clone, Default)]
47 pub community_id: Option<CommunityId>,
48 pub community_name: Option<String>,
49 pub creator_id: Option<PersonId>,
50 pub type_: Option<SearchType>,
51 pub sort: Option<SortType>,
52 pub listing_type: Option<ListingType>,
53 pub page: Option<i64>,
54 pub limit: Option<i64>,
55 pub auth: Option<Sensitive<String>>,
58 #[derive(Debug, Serialize, Deserialize, Clone)]
59 pub struct SearchResponse {
61 pub comments: Vec<CommentView>,
62 pub posts: Vec<PostView>,
63 pub communities: Vec<CommunityView>,
64 pub users: Vec<PersonViewSafe>,
67 #[derive(Debug, Serialize, Deserialize, Clone, Default)]
68 pub struct ResolveObject {
70 pub auth: Option<Sensitive<String>>,
73 #[derive(Debug, Serialize, Deserialize, Default)]
74 pub struct ResolveObjectResponse {
75 pub comment: Option<CommentView>,
76 pub post: Option<PostView>,
77 pub community: Option<CommunityView>,
78 pub person: Option<PersonViewSafe>,
81 #[derive(Debug, Serialize, Deserialize, Clone, Default)]
82 pub struct GetModlog {
83 pub mod_person_id: Option<PersonId>,
84 pub community_id: Option<CommunityId>,
85 pub page: Option<i64>,
86 pub limit: Option<i64>,
87 pub auth: Option<Sensitive<String>>,
88 pub type_: Option<ModlogActionType>,
89 pub other_person_id: Option<PersonId>,
92 #[derive(Debug, Serialize, Deserialize, Clone)]
93 pub struct GetModlogResponse {
94 pub removed_posts: Vec<ModRemovePostView>,
95 pub locked_posts: Vec<ModLockPostView>,
96 pub featured_posts: Vec<ModFeaturePostView>,
97 pub removed_comments: Vec<ModRemoveCommentView>,
98 pub removed_communities: Vec<ModRemoveCommunityView>,
99 pub banned_from_community: Vec<ModBanFromCommunityView>,
100 pub banned: Vec<ModBanView>,
101 pub added_to_community: Vec<ModAddCommunityView>,
102 pub transferred_to_community: Vec<ModTransferCommunityView>,
103 pub added: Vec<ModAddView>,
104 pub admin_purged_persons: Vec<AdminPurgePersonView>,
105 pub admin_purged_communities: Vec<AdminPurgeCommunityView>,
106 pub admin_purged_posts: Vec<AdminPurgePostView>,
107 pub admin_purged_comments: Vec<AdminPurgeCommentView>,
108 pub hidden_communities: Vec<ModHideCommunityView>,
111 #[derive(Debug, Serialize, Deserialize, Clone, Default)]
112 pub struct CreateSite {
114 pub sidebar: Option<String>,
115 pub description: Option<String>,
116 pub icon: Option<String>,
117 pub banner: Option<String>,
118 pub enable_downvotes: Option<bool>,
119 pub open_registration: Option<bool>,
120 pub enable_nsfw: Option<bool>,
121 pub community_creation_admin_only: Option<bool>,
122 pub require_email_verification: Option<bool>,
123 pub require_application: 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<String>,
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 auth: Sensitive<String>,
157 #[derive(Debug, Serialize, Deserialize, Clone, Default)]
158 pub struct EditSite {
159 pub name: Option<String>,
160 pub sidebar: Option<String>,
161 pub description: Option<String>,
162 pub icon: Option<String>,
163 pub banner: Option<String>,
164 pub enable_downvotes: Option<bool>,
165 pub open_registration: 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 require_application: Option<bool>,
170 pub application_question: Option<String>,
171 pub private_instance: Option<bool>,
172 pub default_theme: Option<String>,
173 pub default_post_listing_type: Option<String>,
174 pub legal_information: Option<String>,
175 pub application_email_admins: Option<bool>,
176 pub hide_modlog_mod_names: Option<bool>,
177 pub discussion_languages: Option<Vec<LanguageId>>,
178 pub slur_filter_regex: Option<String>,
179 pub actor_name_max_length: Option<i32>,
180 pub rate_limit_message: Option<i32>,
181 pub rate_limit_message_per_second: Option<i32>,
182 pub rate_limit_post: Option<i32>,
183 pub rate_limit_post_per_second: Option<i32>,
184 pub rate_limit_register: Option<i32>,
185 pub rate_limit_register_per_second: Option<i32>,
186 pub rate_limit_image: Option<i32>,
187 pub rate_limit_image_per_second: Option<i32>,
188 pub rate_limit_comment: Option<i32>,
189 pub rate_limit_comment_per_second: Option<i32>,
190 pub rate_limit_search: Option<i32>,
191 pub rate_limit_search_per_second: Option<i32>,
192 pub federation_enabled: Option<bool>,
193 pub federation_debug: Option<bool>,
194 pub federation_worker_count: Option<i32>,
195 pub captcha_enabled: Option<bool>,
196 pub captcha_difficulty: Option<String>,
197 pub allowed_instances: Option<Vec<String>>,
198 pub blocked_instances: Option<Vec<String>>,
199 pub taglines: Option<Vec<String>>,
200 pub auth: Sensitive<String>,
203 #[derive(Debug, Serialize, Deserialize, Clone, Default)]
205 pub auth: Option<Sensitive<String>>,
208 #[derive(Debug, Serialize, Deserialize, Clone)]
209 pub struct SiteResponse {
210 pub site_view: SiteView,
213 #[derive(Debug, Serialize, Deserialize, Clone)]
214 pub struct GetSiteResponse {
215 pub site_view: SiteView,
216 pub admins: Vec<PersonViewSafe>,
219 pub my_user: Option<MyUserInfo>,
220 pub federated_instances: Option<FederatedInstances>, // Federation may be disabled
221 pub all_languages: Vec<Language>,
222 pub discussion_languages: Vec<LanguageId>,
223 pub taglines: Option<Vec<Tagline>>,
226 #[derive(Debug, Serialize, Deserialize, Clone)]
227 pub struct MyUserInfo {
228 pub local_user_view: LocalUserSettingsView,
229 pub follows: Vec<CommunityFollowerView>,
230 pub moderates: Vec<CommunityModeratorView>,
231 pub community_blocks: Vec<CommunityBlockView>,
232 pub person_blocks: Vec<PersonBlockView>,
233 pub discussion_languages: Vec<LanguageId>,
236 #[derive(Debug, Serialize, Deserialize, Clone)]
237 pub struct LeaveAdmin {
238 pub auth: Sensitive<String>,
241 #[derive(Debug, Serialize, Deserialize, Clone)]
242 pub struct FederatedInstances {
243 pub linked: Vec<String>,
244 pub allowed: Option<Vec<String>>,
245 pub blocked: Option<Vec<String>>,
248 #[derive(Debug, Serialize, Deserialize, Clone)]
249 pub struct PurgePerson {
250 pub person_id: PersonId,
251 pub reason: Option<String>,
255 #[derive(Debug, Serialize, Deserialize, Clone)]
256 pub struct PurgeCommunity {
257 pub community_id: CommunityId,
258 pub reason: Option<String>,
262 #[derive(Debug, Serialize, Deserialize, Clone)]
263 pub struct PurgePost {
265 pub reason: Option<String>,
269 #[derive(Debug, Serialize, Deserialize, Clone)]
270 pub struct PurgeComment {
271 pub comment_id: CommentId,
272 pub reason: Option<String>,
276 #[derive(Serialize, Deserialize)]
277 pub struct PurgeItemResponse {
281 #[derive(Debug, Serialize, Deserialize, Clone, Default)]
282 pub struct ListRegistrationApplications {
283 /// Only shows the unread applications (IE those without an admin actor)
284 pub unread_only: Option<bool>,
285 pub page: Option<i64>,
286 pub limit: Option<i64>,
290 #[derive(Debug, Serialize, Deserialize, Clone)]
291 pub struct ListRegistrationApplicationsResponse {
292 pub registration_applications: Vec<RegistrationApplicationView>,
295 #[derive(Debug, Serialize, Deserialize, Clone, Default)]
296 pub struct ApproveRegistrationApplication {
299 pub deny_reason: Option<String>,
303 #[derive(Debug, Serialize, Deserialize, Clone)]
304 pub struct RegistrationApplicationResponse {
305 pub registration_application: RegistrationApplicationView,
308 #[derive(Debug, Serialize, Deserialize, Clone)]
309 pub struct GetUnreadRegistrationApplicationCount {
313 #[derive(Debug, Serialize, Deserialize, Clone)]
314 pub struct GetUnreadRegistrationApplicationCountResponse {
315 pub registration_applications: i64,