1 use lemmy_db_schema::newtypes::{CommunityId, PersonId};
3 comment_view::CommentView,
4 local_user_view::LocalUserSettingsView,
6 registration_application_view::RegistrationApplicationView,
9 use lemmy_db_views_actor::{
10 community_block_view::CommunityBlockView,
11 community_follower_view::CommunityFollowerView,
12 community_moderator_view::CommunityModeratorView,
13 community_view::CommunityView,
14 person_block_view::PersonBlockView,
15 person_view::PersonViewSafe,
17 use lemmy_db_views_moderator::{
18 mod_add_community_view::ModAddCommunityView,
19 mod_add_view::ModAddView,
20 mod_ban_from_community_view::ModBanFromCommunityView,
21 mod_ban_view::ModBanView,
22 mod_hide_community_view::ModHideCommunityView,
23 mod_lock_post_view::ModLockPostView,
24 mod_remove_comment_view::ModRemoveCommentView,
25 mod_remove_community_view::ModRemoveCommunityView,
26 mod_remove_post_view::ModRemovePostView,
27 mod_sticky_post_view::ModStickyPostView,
28 mod_transfer_community_view::ModTransferCommunityView,
30 use lemmy_utils::Sensitive;
31 use serde::{Deserialize, Serialize};
33 #[derive(Serialize, Deserialize, Debug)]
36 pub community_id: Option<CommunityId>,
37 pub community_name: Option<String>,
38 pub creator_id: Option<PersonId>,
39 pub type_: Option<String>,
40 pub sort: Option<String>,
41 pub listing_type: Option<String>,
42 pub page: Option<i64>,
43 pub limit: Option<i64>,
44 pub auth: Option<Sensitive<String>>,
47 #[derive(Serialize, Deserialize, Debug)]
48 pub struct SearchResponse {
50 pub comments: Vec<CommentView>,
51 pub posts: Vec<PostView>,
52 pub communities: Vec<CommunityView>,
53 pub users: Vec<PersonViewSafe>,
56 #[derive(Serialize, Deserialize, Debug)]
57 pub struct ResolveObject {
59 pub auth: Option<Sensitive<String>>,
62 #[derive(Debug, Serialize, Deserialize, Default)]
63 pub struct ResolveObjectResponse {
64 pub comment: Option<CommentView>,
65 pub post: Option<PostView>,
66 pub community: Option<CommunityView>,
67 pub person: Option<PersonViewSafe>,
70 #[derive(Debug, Serialize, Deserialize)]
71 pub struct GetModlog {
72 pub mod_person_id: Option<PersonId>,
73 pub community_id: Option<CommunityId>,
74 pub page: Option<i64>,
75 pub limit: Option<i64>,
76 pub auth: Option<Sensitive<String>>,
79 #[derive(Debug, Serialize, Deserialize)]
80 pub struct GetModlogResponse {
81 pub removed_posts: Vec<ModRemovePostView>,
82 pub locked_posts: Vec<ModLockPostView>,
83 pub stickied_posts: Vec<ModStickyPostView>,
84 pub removed_comments: Vec<ModRemoveCommentView>,
85 pub removed_communities: Vec<ModRemoveCommunityView>,
86 pub banned_from_community: Vec<ModBanFromCommunityView>,
87 pub banned: Vec<ModBanView>,
88 pub added_to_community: Vec<ModAddCommunityView>,
89 pub transferred_to_community: Vec<ModTransferCommunityView>,
90 pub added: Vec<ModAddView>,
91 pub hidden_communities: Vec<ModHideCommunityView>,
94 #[derive(Debug, Serialize, Deserialize)]
95 pub struct CreateSite {
97 pub sidebar: Option<String>,
98 pub description: Option<String>,
99 pub icon: Option<String>,
100 pub banner: Option<String>,
101 pub enable_downvotes: Option<bool>,
102 pub open_registration: Option<bool>,
103 pub enable_nsfw: Option<bool>,
104 pub community_creation_admin_only: Option<bool>,
105 pub require_email_verification: Option<bool>,
106 pub require_application: Option<bool>,
107 pub application_question: Option<String>,
108 pub private_instance: Option<bool>,
109 pub default_theme: Option<String>,
110 pub auth: Sensitive<String>,
113 #[derive(Debug, Serialize, Deserialize)]
114 pub struct EditSite {
115 pub name: Option<String>,
116 pub sidebar: Option<String>,
117 pub description: Option<String>,
118 pub icon: Option<String>,
119 pub banner: Option<String>,
120 pub enable_downvotes: Option<bool>,
121 pub open_registration: Option<bool>,
122 pub enable_nsfw: Option<bool>,
123 pub community_creation_admin_only: Option<bool>,
124 pub require_email_verification: Option<bool>,
125 pub require_application: Option<bool>,
126 pub application_question: Option<String>,
127 pub private_instance: Option<bool>,
128 pub default_theme: Option<String>,
129 pub auth: Sensitive<String>,
132 #[derive(Debug, Serialize, Deserialize)]
134 pub auth: Option<Sensitive<String>>,
137 #[derive(Debug, Serialize, Deserialize, Clone)]
138 pub struct SiteResponse {
139 pub site_view: SiteView,
142 #[derive(Debug, Serialize, Deserialize)]
143 pub struct GetSiteResponse {
144 pub site_view: Option<SiteView>, // Because the site might not be set up yet
145 pub admins: Vec<PersonViewSafe>,
148 pub my_user: Option<MyUserInfo>,
149 pub federated_instances: Option<FederatedInstances>, // Federation may be disabled
152 #[derive(Debug, Serialize, Deserialize)]
153 pub struct MyUserInfo {
154 pub local_user_view: LocalUserSettingsView,
155 pub follows: Vec<CommunityFollowerView>,
156 pub moderates: Vec<CommunityModeratorView>,
157 pub community_blocks: Vec<CommunityBlockView>,
158 pub person_blocks: Vec<PersonBlockView>,
161 #[derive(Debug, Serialize, Deserialize)]
162 pub struct LeaveAdmin {
163 pub auth: Sensitive<String>,
166 #[derive(Debug, Serialize, Deserialize)]
167 pub struct GetSiteConfig {
168 pub auth: Sensitive<String>,
171 #[derive(Debug, Serialize, Deserialize)]
172 pub struct GetSiteConfigResponse {
173 pub config_hjson: String,
176 #[derive(Debug, Serialize, Deserialize)]
177 pub struct SaveSiteConfig {
178 pub config_hjson: String,
179 pub auth: Sensitive<String>,
182 #[derive(Debug, Serialize, Deserialize)]
183 pub struct FederatedInstances {
184 pub linked: Vec<String>,
185 pub allowed: Option<Vec<String>>,
186 pub blocked: Option<Vec<String>>,
189 #[derive(Serialize, Deserialize)]
190 pub struct ListRegistrationApplications {
191 /// Only shows the unread applications (IE those without an admin actor)
192 pub unread_only: Option<bool>,
193 pub page: Option<i64>,
194 pub limit: Option<i64>,
198 #[derive(Serialize, Deserialize)]
199 pub struct ListRegistrationApplicationsResponse {
200 pub registration_applications: Vec<RegistrationApplicationView>,
203 #[derive(Serialize, Deserialize)]
204 pub struct ApproveRegistrationApplication {
207 pub deny_reason: Option<String>,
211 #[derive(Serialize, Deserialize)]
212 pub struct RegistrationApplicationResponse {
213 pub registration_application: RegistrationApplicationView,
216 #[derive(Serialize, Deserialize)]
217 pub struct GetUnreadRegistrationApplicationCount {
221 #[derive(Serialize, Deserialize, Clone)]
222 pub struct GetUnreadRegistrationApplicationCountResponse {
223 pub registration_applications: i64,