1 use crate::sensitive::Sensitive;
3 newtypes::{CommentId, CommunityId, PersonId, PostId},
9 use lemmy_db_views::structs::{
11 LocalUserSettingsView,
13 RegistrationApplicationView,
16 use lemmy_db_views_actor::structs::{
18 CommunityFollowerView,
19 CommunityModeratorView,
24 use lemmy_db_views_moderator::structs::{
25 AdminPurgeCommentView,
26 AdminPurgeCommunityView,
31 ModBanFromCommunityView,
36 ModRemoveCommunityView,
39 ModTransferCommunityView,
41 use serde::{Deserialize, Serialize};
43 #[derive(Debug, Serialize, Deserialize, Clone, Default)]
46 pub community_id: Option<CommunityId>,
47 pub community_name: Option<String>,
48 pub creator_id: Option<PersonId>,
49 pub type_: Option<SearchType>,
50 pub sort: Option<SortType>,
51 pub listing_type: Option<ListingType>,
52 pub page: Option<i64>,
53 pub limit: Option<i64>,
54 pub auth: Option<Sensitive<String>>,
57 #[derive(Debug, Serialize, Deserialize, Clone)]
58 pub struct SearchResponse {
60 pub comments: Vec<CommentView>,
61 pub posts: Vec<PostView>,
62 pub communities: Vec<CommunityView>,
63 pub users: Vec<PersonViewSafe>,
66 #[derive(Debug, Serialize, Deserialize, Clone, Default)]
67 pub struct ResolveObject {
69 pub auth: Option<Sensitive<String>>,
72 #[derive(Debug, Serialize, Deserialize, Default)]
73 pub struct ResolveObjectResponse {
74 pub comment: Option<CommentView>,
75 pub post: Option<PostView>,
76 pub community: Option<CommunityView>,
77 pub person: Option<PersonViewSafe>,
80 #[derive(Debug, Serialize, Deserialize, Clone, Default)]
81 pub struct GetModlog {
82 pub mod_person_id: Option<PersonId>,
83 pub community_id: Option<CommunityId>,
84 pub page: Option<i64>,
85 pub limit: Option<i64>,
86 pub auth: Option<Sensitive<String>>,
87 pub type_: Option<ModlogActionType>,
88 pub other_person_id: Option<PersonId>,
91 #[derive(Debug, Serialize, Deserialize, Clone)]
92 pub struct GetModlogResponse {
93 pub removed_posts: Vec<ModRemovePostView>,
94 pub locked_posts: Vec<ModLockPostView>,
95 pub stickied_posts: Vec<ModStickyPostView>,
96 pub removed_comments: Vec<ModRemoveCommentView>,
97 pub removed_communities: Vec<ModRemoveCommunityView>,
98 pub banned_from_community: Vec<ModBanFromCommunityView>,
99 pub banned: Vec<ModBanView>,
100 pub added_to_community: Vec<ModAddCommunityView>,
101 pub transferred_to_community: Vec<ModTransferCommunityView>,
102 pub added: Vec<ModAddView>,
103 pub admin_purged_persons: Vec<AdminPurgePersonView>,
104 pub admin_purged_communities: Vec<AdminPurgeCommunityView>,
105 pub admin_purged_posts: Vec<AdminPurgePostView>,
106 pub admin_purged_comments: Vec<AdminPurgeCommentView>,
107 pub hidden_communities: Vec<ModHideCommunityView>,
110 #[derive(Debug, Serialize, Deserialize, Clone, Default)]
111 pub struct CreateSite {
113 pub sidebar: Option<String>,
114 pub description: Option<String>,
115 pub icon: Option<String>,
116 pub banner: Option<String>,
117 pub enable_downvotes: Option<bool>,
118 pub open_registration: 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 require_application: Option<bool>,
123 pub application_question: Option<String>,
124 pub private_instance: Option<bool>,
125 pub default_theme: Option<String>,
126 pub default_post_listing_type: Option<String>,
127 pub auth: Sensitive<String>,
128 pub hide_modlog_mod_names: Option<bool>,
131 #[derive(Debug, Serialize, Deserialize, Clone, Default)]
132 pub struct EditSite {
133 pub name: Option<String>,
134 pub sidebar: Option<String>,
135 pub description: Option<String>,
136 pub icon: Option<String>,
137 pub banner: Option<String>,
138 pub enable_downvotes: Option<bool>,
139 pub open_registration: Option<bool>,
140 pub enable_nsfw: Option<bool>,
141 pub community_creation_admin_only: Option<bool>,
142 pub require_email_verification: Option<bool>,
143 pub require_application: Option<bool>,
144 pub application_question: Option<String>,
145 pub private_instance: Option<bool>,
146 pub default_theme: Option<String>,
147 pub default_post_listing_type: Option<String>,
148 pub legal_information: Option<String>,
149 pub auth: Sensitive<String>,
150 pub hide_modlog_mod_names: Option<bool>,
153 #[derive(Debug, Serialize, Deserialize, Clone, Default)]
155 pub auth: Option<Sensitive<String>>,
158 #[derive(Debug, Serialize, Deserialize, Clone)]
159 pub struct SiteResponse {
160 pub site_view: SiteView,
163 #[derive(Debug, Serialize, Deserialize, Clone)]
164 pub struct GetSiteResponse {
165 pub site_view: Option<SiteView>, // Because the site might not be set up yet
166 pub admins: Vec<PersonViewSafe>,
169 pub my_user: Option<MyUserInfo>,
170 pub federated_instances: Option<FederatedInstances>, // Federation may be disabled
173 #[derive(Debug, Serialize, Deserialize, Clone)]
174 pub struct MyUserInfo {
175 pub local_user_view: LocalUserSettingsView,
176 pub follows: Vec<CommunityFollowerView>,
177 pub moderates: Vec<CommunityModeratorView>,
178 pub community_blocks: Vec<CommunityBlockView>,
179 pub person_blocks: Vec<PersonBlockView>,
182 #[derive(Debug, Serialize, Deserialize, Clone)]
183 pub struct LeaveAdmin {
184 pub auth: Sensitive<String>,
187 #[derive(Debug, Serialize, Deserialize, Clone)]
188 pub struct FederatedInstances {
189 pub linked: Vec<String>,
190 pub allowed: Option<Vec<String>>,
191 pub blocked: Option<Vec<String>>,
194 #[derive(Debug, Serialize, Deserialize, Clone)]
195 pub struct PurgePerson {
196 pub person_id: PersonId,
197 pub reason: Option<String>,
201 #[derive(Debug, Serialize, Deserialize, Clone)]
202 pub struct PurgeCommunity {
203 pub community_id: CommunityId,
204 pub reason: Option<String>,
208 #[derive(Debug, Serialize, Deserialize, Clone)]
209 pub struct PurgePost {
211 pub reason: Option<String>,
215 #[derive(Debug, Serialize, Deserialize, Clone)]
216 pub struct PurgeComment {
217 pub comment_id: CommentId,
218 pub reason: Option<String>,
222 #[derive(Serialize, Deserialize)]
223 pub struct PurgeItemResponse {
227 #[derive(Debug, Serialize, Deserialize, Clone, Default)]
228 pub struct ListRegistrationApplications {
229 /// Only shows the unread applications (IE those without an admin actor)
230 pub unread_only: Option<bool>,
231 pub page: Option<i64>,
232 pub limit: Option<i64>,
236 #[derive(Debug, Serialize, Deserialize, Clone)]
237 pub struct ListRegistrationApplicationsResponse {
238 pub registration_applications: Vec<RegistrationApplicationView>,
241 #[derive(Debug, Serialize, Deserialize, Clone, Default)]
242 pub struct ApproveRegistrationApplication {
245 pub deny_reason: Option<String>,
249 #[derive(Debug, Serialize, Deserialize, Clone)]
250 pub struct RegistrationApplicationResponse {
251 pub registration_application: RegistrationApplicationView,
254 #[derive(Debug, Serialize, Deserialize, Clone)]
255 pub struct GetUnreadRegistrationApplicationCount {
259 #[derive(Debug, Serialize, Deserialize, Clone)]
260 pub struct GetUnreadRegistrationApplicationCountResponse {
261 pub registration_applications: i64,