1 use crate::sensitive::Sensitive;
3 newtypes::{CommentId, CommunityId, LanguageId, PersonId, PostId},
4 source::language::Language,
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,
37 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 stickied_posts: Vec<ModStickyPostView>,
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 application_email_admins: Option<bool>,
129 pub auth: Sensitive<String>,
130 pub hide_modlog_mod_names: Option<bool>,
133 #[derive(Debug, Serialize, Deserialize, Clone, Default)]
134 pub struct EditSite {
135 pub name: Option<String>,
136 pub sidebar: Option<String>,
137 pub description: Option<String>,
138 pub icon: Option<String>,
139 pub banner: Option<String>,
140 pub enable_downvotes: Option<bool>,
141 pub open_registration: Option<bool>,
142 pub enable_nsfw: Option<bool>,
143 pub community_creation_admin_only: Option<bool>,
144 pub require_email_verification: Option<bool>,
145 pub require_application: Option<bool>,
146 pub application_question: Option<String>,
147 pub private_instance: Option<bool>,
148 pub default_theme: Option<String>,
149 pub default_post_listing_type: Option<String>,
150 pub legal_information: Option<String>,
151 pub application_email_admins: Option<bool>,
152 pub hide_modlog_mod_names: Option<bool>,
153 pub discussion_languages: Option<Vec<LanguageId>>,
154 pub auth: Sensitive<String>,
157 #[derive(Debug, Serialize, Deserialize, Clone, Default)]
159 pub auth: Option<Sensitive<String>>,
162 #[derive(Debug, Serialize, Deserialize, Clone)]
163 pub struct SiteResponse {
164 pub site_view: SiteView,
167 #[derive(Debug, Serialize, Deserialize, Clone)]
168 pub struct GetSiteResponse {
169 pub site_view: Option<SiteView>, // Because the site might not be set up yet
170 pub admins: Vec<PersonViewSafe>,
173 pub my_user: Option<MyUserInfo>,
174 pub federated_instances: Option<FederatedInstances>, // Federation may be disabled
175 pub all_languages: Vec<Language>,
176 pub discussion_languages: Vec<LanguageId>,
179 #[derive(Debug, Serialize, Deserialize, Clone)]
180 pub struct MyUserInfo {
181 pub local_user_view: LocalUserSettingsView,
182 pub follows: Vec<CommunityFollowerView>,
183 pub moderates: Vec<CommunityModeratorView>,
184 pub community_blocks: Vec<CommunityBlockView>,
185 pub person_blocks: Vec<PersonBlockView>,
186 pub discussion_languages: Vec<Language>,
189 #[derive(Debug, Serialize, Deserialize, Clone)]
190 pub struct LeaveAdmin {
191 pub auth: Sensitive<String>,
194 #[derive(Debug, Serialize, Deserialize, Clone)]
195 pub struct FederatedInstances {
196 pub linked: Vec<String>,
197 pub allowed: Option<Vec<String>>,
198 pub blocked: Option<Vec<String>>,
201 #[derive(Debug, Serialize, Deserialize, Clone)]
202 pub struct PurgePerson {
203 pub person_id: PersonId,
204 pub reason: Option<String>,
208 #[derive(Debug, Serialize, Deserialize, Clone)]
209 pub struct PurgeCommunity {
210 pub community_id: CommunityId,
211 pub reason: Option<String>,
215 #[derive(Debug, Serialize, Deserialize, Clone)]
216 pub struct PurgePost {
218 pub reason: Option<String>,
222 #[derive(Debug, Serialize, Deserialize, Clone)]
223 pub struct PurgeComment {
224 pub comment_id: CommentId,
225 pub reason: Option<String>,
229 #[derive(Serialize, Deserialize)]
230 pub struct PurgeItemResponse {
234 #[derive(Debug, Serialize, Deserialize, Clone, Default)]
235 pub struct ListRegistrationApplications {
236 /// Only shows the unread applications (IE those without an admin actor)
237 pub unread_only: Option<bool>,
238 pub page: Option<i64>,
239 pub limit: Option<i64>,
243 #[derive(Debug, Serialize, Deserialize, Clone)]
244 pub struct ListRegistrationApplicationsResponse {
245 pub registration_applications: Vec<RegistrationApplicationView>,
248 #[derive(Debug, Serialize, Deserialize, Clone, Default)]
249 pub struct ApproveRegistrationApplication {
252 pub deny_reason: Option<String>,
256 #[derive(Debug, Serialize, Deserialize, Clone)]
257 pub struct RegistrationApplicationResponse {
258 pub registration_application: RegistrationApplicationView,
261 #[derive(Debug, Serialize, Deserialize, Clone)]
262 pub struct GetUnreadRegistrationApplicationCount {
266 #[derive(Debug, Serialize, Deserialize, Clone)]
267 pub struct GetUnreadRegistrationApplicationCountResponse {
268 pub registration_applications: i64,