1 use crate::sensitive::Sensitive;
3 newtypes::{CommentId, CommunityId, LanguageId, PersonId, PostId},
4 source::{language::Language, local_site::RegistrationMode, 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 enable_nsfw: Option<bool>,
120 pub community_creation_admin_only: Option<bool>,
121 pub require_email_verification: Option<bool>,
122 pub application_question: Option<String>,
123 pub private_instance: Option<bool>,
124 pub default_theme: Option<String>,
125 pub default_post_listing_type: Option<String>,
126 pub legal_information: Option<String>,
127 pub application_email_admins: Option<bool>,
128 pub hide_modlog_mod_names: Option<bool>,
129 pub discussion_languages: Option<Vec<LanguageId>>,
130 pub slur_filter_regex: Option<String>,
131 pub actor_name_max_length: Option<i32>,
132 pub rate_limit_message: Option<i32>,
133 pub rate_limit_message_per_second: Option<i32>,
134 pub rate_limit_post: Option<i32>,
135 pub rate_limit_post_per_second: Option<i32>,
136 pub rate_limit_register: Option<i32>,
137 pub rate_limit_register_per_second: Option<i32>,
138 pub rate_limit_image: Option<i32>,
139 pub rate_limit_image_per_second: Option<i32>,
140 pub rate_limit_comment: Option<i32>,
141 pub rate_limit_comment_per_second: Option<i32>,
142 pub rate_limit_search: Option<i32>,
143 pub rate_limit_search_per_second: Option<i32>,
144 pub federation_enabled: Option<bool>,
145 pub federation_debug: Option<bool>,
146 pub federation_worker_count: Option<i32>,
147 pub captcha_enabled: Option<bool>,
148 pub captcha_difficulty: Option<String>,
149 pub allowed_instances: Option<Vec<String>>,
150 pub blocked_instances: Option<Vec<String>>,
151 pub taglines: Option<Vec<String>>,
152 pub registration_mode: Option<RegistrationMode>,
153 pub auth: Sensitive<String>,
156 #[derive(Debug, Serialize, Deserialize, Clone, Default)]
157 pub struct EditSite {
158 pub name: Option<String>,
159 pub sidebar: Option<String>,
160 pub description: Option<String>,
161 pub icon: Option<String>,
162 pub banner: Option<String>,
163 pub enable_downvotes: Option<bool>,
164 pub enable_nsfw: Option<bool>,
165 pub community_creation_admin_only: Option<bool>,
166 pub require_email_verification: Option<bool>,
167 pub application_question: Option<String>,
168 pub private_instance: Option<bool>,
169 pub default_theme: Option<String>,
170 pub default_post_listing_type: Option<String>,
171 pub legal_information: Option<String>,
172 pub application_email_admins: Option<bool>,
173 pub hide_modlog_mod_names: Option<bool>,
174 pub discussion_languages: Option<Vec<LanguageId>>,
175 pub slur_filter_regex: Option<String>,
176 pub actor_name_max_length: Option<i32>,
177 pub rate_limit_message: Option<i32>,
178 pub rate_limit_message_per_second: Option<i32>,
179 pub rate_limit_post: Option<i32>,
180 pub rate_limit_post_per_second: Option<i32>,
181 pub rate_limit_register: Option<i32>,
182 pub rate_limit_register_per_second: Option<i32>,
183 pub rate_limit_image: Option<i32>,
184 pub rate_limit_image_per_second: Option<i32>,
185 pub rate_limit_comment: Option<i32>,
186 pub rate_limit_comment_per_second: Option<i32>,
187 pub rate_limit_search: Option<i32>,
188 pub rate_limit_search_per_second: Option<i32>,
189 pub federation_enabled: Option<bool>,
190 pub federation_debug: Option<bool>,
191 pub federation_worker_count: Option<i32>,
192 pub captcha_enabled: Option<bool>,
193 pub captcha_difficulty: Option<String>,
194 pub allowed_instances: Option<Vec<String>>,
195 pub blocked_instances: Option<Vec<String>>,
196 pub taglines: Option<Vec<String>>,
197 pub registration_mode: Option<RegistrationMode>,
198 pub auth: Sensitive<String>,
201 #[derive(Debug, Serialize, Deserialize, Clone, Default)]
203 pub auth: Option<Sensitive<String>>,
206 #[derive(Debug, Serialize, Deserialize, Clone)]
207 pub struct SiteResponse {
208 pub site_view: SiteView,
211 #[derive(Debug, Serialize, Deserialize, Clone)]
212 pub struct GetSiteResponse {
213 pub site_view: SiteView,
214 pub admins: Vec<PersonViewSafe>,
217 pub my_user: Option<MyUserInfo>,
218 pub federated_instances: Option<FederatedInstances>, // Federation may be disabled
219 pub all_languages: Vec<Language>,
220 pub discussion_languages: Vec<LanguageId>,
221 pub taglines: Option<Vec<Tagline>>,
224 #[derive(Debug, Serialize, Deserialize, Clone)]
225 pub struct MyUserInfo {
226 pub local_user_view: LocalUserSettingsView,
227 pub follows: Vec<CommunityFollowerView>,
228 pub moderates: Vec<CommunityModeratorView>,
229 pub community_blocks: Vec<CommunityBlockView>,
230 pub person_blocks: Vec<PersonBlockView>,
231 pub discussion_languages: Vec<LanguageId>,
234 #[derive(Debug, Serialize, Deserialize, Clone)]
235 pub struct LeaveAdmin {
236 pub auth: Sensitive<String>,
239 #[derive(Debug, Serialize, Deserialize, Clone)]
240 pub struct FederatedInstances {
241 pub linked: Vec<String>,
242 pub allowed: Option<Vec<String>>,
243 pub blocked: Option<Vec<String>>,
246 #[derive(Debug, Serialize, Deserialize, Clone)]
247 pub struct PurgePerson {
248 pub person_id: PersonId,
249 pub reason: Option<String>,
253 #[derive(Debug, Serialize, Deserialize, Clone)]
254 pub struct PurgeCommunity {
255 pub community_id: CommunityId,
256 pub reason: Option<String>,
260 #[derive(Debug, Serialize, Deserialize, Clone)]
261 pub struct PurgePost {
263 pub reason: Option<String>,
267 #[derive(Debug, Serialize, Deserialize, Clone)]
268 pub struct PurgeComment {
269 pub comment_id: CommentId,
270 pub reason: Option<String>,
274 #[derive(Serialize, Deserialize)]
275 pub struct PurgeItemResponse {
279 #[derive(Debug, Serialize, Deserialize, Clone, Default)]
280 pub struct ListRegistrationApplications {
281 /// Only shows the unread applications (IE those without an admin actor)
282 pub unread_only: Option<bool>,
283 pub page: Option<i64>,
284 pub limit: Option<i64>,
288 #[derive(Debug, Serialize, Deserialize, Clone)]
289 pub struct ListRegistrationApplicationsResponse {
290 pub registration_applications: Vec<RegistrationApplicationView>,
293 #[derive(Debug, Serialize, Deserialize, Clone, Default)]
294 pub struct ApproveRegistrationApplication {
297 pub deny_reason: Option<String>,
301 #[derive(Debug, Serialize, Deserialize, Clone)]
302 pub struct RegistrationApplicationResponse {
303 pub registration_application: RegistrationApplicationView,
306 #[derive(Debug, Serialize, Deserialize, Clone)]
307 pub struct GetUnreadRegistrationApplicationCount {
311 #[derive(Debug, Serialize, Deserialize, Clone)]
312 pub struct GetUnreadRegistrationApplicationCountResponse {
313 pub registration_applications: i64,