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 default_post_listing_type: Option<String>,
111 pub auth: Sensitive<String>,
114 #[derive(Debug, Serialize, Deserialize)]
115 pub struct EditSite {
116 pub name: Option<String>,
117 pub sidebar: Option<String>,
118 pub description: Option<String>,
119 pub icon: Option<String>,
120 pub banner: Option<String>,
121 pub enable_downvotes: Option<bool>,
122 pub open_registration: Option<bool>,
123 pub enable_nsfw: Option<bool>,
124 pub community_creation_admin_only: Option<bool>,
125 pub require_email_verification: Option<bool>,
126 pub require_application: Option<bool>,
127 pub application_question: Option<String>,
128 pub private_instance: Option<bool>,
129 pub default_theme: Option<String>,
130 pub default_post_listing_type: Option<String>,
131 pub auth: Sensitive<String>,
134 #[derive(Debug, Serialize, Deserialize)]
136 pub auth: Option<Sensitive<String>>,
139 #[derive(Debug, Serialize, Deserialize, Clone)]
140 pub struct SiteResponse {
141 pub site_view: SiteView,
144 #[derive(Debug, Serialize, Deserialize)]
145 pub struct GetSiteResponse {
146 pub site_view: Option<SiteView>, // Because the site might not be set up yet
147 pub admins: Vec<PersonViewSafe>,
150 pub my_user: Option<MyUserInfo>,
151 pub federated_instances: Option<FederatedInstances>, // Federation may be disabled
154 #[derive(Debug, Serialize, Deserialize)]
155 pub struct MyUserInfo {
156 pub local_user_view: LocalUserSettingsView,
157 pub follows: Vec<CommunityFollowerView>,
158 pub moderates: Vec<CommunityModeratorView>,
159 pub community_blocks: Vec<CommunityBlockView>,
160 pub person_blocks: Vec<PersonBlockView>,
163 #[derive(Debug, Serialize, Deserialize)]
164 pub struct LeaveAdmin {
165 pub auth: Sensitive<String>,
168 #[derive(Debug, Serialize, Deserialize)]
169 pub struct GetSiteConfig {
170 pub auth: Sensitive<String>,
173 #[derive(Debug, Serialize, Deserialize)]
174 pub struct GetSiteConfigResponse {
175 pub config_hjson: String,
178 #[derive(Debug, Serialize, Deserialize)]
179 pub struct SaveSiteConfig {
180 pub config_hjson: String,
181 pub auth: Sensitive<String>,
184 #[derive(Debug, Serialize, Deserialize)]
185 pub struct FederatedInstances {
186 pub linked: Vec<String>,
187 pub allowed: Option<Vec<String>>,
188 pub blocked: Option<Vec<String>>,
191 #[derive(Serialize, Deserialize)]
192 pub struct ListRegistrationApplications {
193 /// Only shows the unread applications (IE those without an admin actor)
194 pub unread_only: Option<bool>,
195 pub page: Option<i64>,
196 pub limit: Option<i64>,
200 #[derive(Serialize, Deserialize)]
201 pub struct ListRegistrationApplicationsResponse {
202 pub registration_applications: Vec<RegistrationApplicationView>,
205 #[derive(Serialize, Deserialize)]
206 pub struct ApproveRegistrationApplication {
209 pub deny_reason: Option<String>,
213 #[derive(Serialize, Deserialize)]
214 pub struct RegistrationApplicationResponse {
215 pub registration_application: RegistrationApplicationView,
218 #[derive(Serialize, Deserialize)]
219 pub struct GetUnreadRegistrationApplicationCount {
223 #[derive(Serialize, Deserialize, Clone)]
224 pub struct GetUnreadRegistrationApplicationCountResponse {
225 pub registration_applications: i64,