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_lock_post_view::ModLockPostView,
23 mod_remove_comment_view::ModRemoveCommentView,
24 mod_remove_community_view::ModRemoveCommunityView,
25 mod_remove_post_view::ModRemovePostView,
26 mod_sticky_post_view::ModStickyPostView,
27 mod_transfer_community_view::ModTransferCommunityView,
29 use lemmy_utils::Sensitive;
30 use serde::{Deserialize, Serialize};
32 #[derive(Serialize, Deserialize, Debug)]
35 pub community_id: Option<CommunityId>,
36 pub community_name: Option<String>,
37 pub creator_id: Option<PersonId>,
38 pub type_: Option<String>,
39 pub sort: Option<String>,
40 pub listing_type: Option<String>,
41 pub page: Option<i64>,
42 pub limit: Option<i64>,
43 pub auth: Option<Sensitive<String>>,
46 #[derive(Serialize, Deserialize, Debug)]
47 pub struct SearchResponse {
49 pub comments: Vec<CommentView>,
50 pub posts: Vec<PostView>,
51 pub communities: Vec<CommunityView>,
52 pub users: Vec<PersonViewSafe>,
55 #[derive(Serialize, Deserialize, Debug)]
56 pub struct ResolveObject {
58 pub auth: Option<Sensitive<String>>,
61 #[derive(Debug, Serialize, Deserialize, Default)]
62 pub struct ResolveObjectResponse {
63 pub comment: Option<CommentView>,
64 pub post: Option<PostView>,
65 pub community: Option<CommunityView>,
66 pub person: Option<PersonViewSafe>,
69 #[derive(Debug, Serialize, Deserialize)]
70 pub struct GetModlog {
71 pub mod_person_id: Option<PersonId>,
72 pub community_id: Option<CommunityId>,
73 pub page: Option<i64>,
74 pub limit: Option<i64>,
75 pub auth: Option<Sensitive<String>>,
78 #[derive(Debug, Serialize, Deserialize)]
79 pub struct GetModlogResponse {
80 pub removed_posts: Vec<ModRemovePostView>,
81 pub locked_posts: Vec<ModLockPostView>,
82 pub stickied_posts: Vec<ModStickyPostView>,
83 pub removed_comments: Vec<ModRemoveCommentView>,
84 pub removed_communities: Vec<ModRemoveCommunityView>,
85 pub banned_from_community: Vec<ModBanFromCommunityView>,
86 pub banned: Vec<ModBanView>,
87 pub added_to_community: Vec<ModAddCommunityView>,
88 pub transferred_to_community: Vec<ModTransferCommunityView>,
89 pub added: Vec<ModAddView>,
92 #[derive(Debug, Serialize, Deserialize)]
93 pub struct CreateSite {
95 pub sidebar: Option<String>,
96 pub description: Option<String>,
97 pub icon: Option<String>,
98 pub banner: Option<String>,
99 pub enable_downvotes: Option<bool>,
100 pub open_registration: Option<bool>,
101 pub enable_nsfw: Option<bool>,
102 pub community_creation_admin_only: Option<bool>,
103 pub require_email_verification: Option<bool>,
104 pub require_application: Option<bool>,
105 pub application_question: Option<String>,
106 pub private_instance: Option<bool>,
107 pub auth: Sensitive<String>,
110 #[derive(Debug, Serialize, Deserialize)]
111 pub struct EditSite {
112 pub name: Option<String>,
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 auth: Sensitive<String>,
128 #[derive(Debug, Serialize, Deserialize)]
130 pub auth: Option<Sensitive<String>>,
133 #[derive(Debug, Serialize, Deserialize, Clone)]
134 pub struct SiteResponse {
135 pub site_view: SiteView,
138 #[derive(Debug, Serialize, Deserialize)]
139 pub struct GetSiteResponse {
140 pub site_view: Option<SiteView>, // Because the site might not be set up yet
141 pub admins: Vec<PersonViewSafe>,
144 pub my_user: Option<MyUserInfo>,
145 pub federated_instances: Option<FederatedInstances>, // Federation may be disabled
148 #[derive(Debug, Serialize, Deserialize)]
149 pub struct MyUserInfo {
150 pub local_user_view: LocalUserSettingsView,
151 pub follows: Vec<CommunityFollowerView>,
152 pub moderates: Vec<CommunityModeratorView>,
153 pub community_blocks: Vec<CommunityBlockView>,
154 pub person_blocks: Vec<PersonBlockView>,
157 #[derive(Debug, Serialize, Deserialize)]
158 pub struct TransferSite {
159 pub person_id: PersonId,
160 pub auth: Sensitive<String>,
163 #[derive(Debug, Serialize, Deserialize)]
164 pub struct GetSiteConfig {
165 pub auth: Sensitive<String>,
168 #[derive(Debug, Serialize, Deserialize)]
169 pub struct GetSiteConfigResponse {
170 pub config_hjson: String,
173 #[derive(Debug, Serialize, Deserialize)]
174 pub struct SaveSiteConfig {
175 pub config_hjson: String,
176 pub auth: Sensitive<String>,
179 #[derive(Debug, Serialize, Deserialize)]
180 pub struct FederatedInstances {
181 pub linked: Vec<String>,
182 pub allowed: Option<Vec<String>>,
183 pub blocked: Option<Vec<String>>,
186 #[derive(Serialize, Deserialize)]
187 pub struct ListRegistrationApplications {
188 /// Only shows the unread applications (IE those without an admin actor)
189 pub unread_only: Option<bool>,
190 pub page: Option<i64>,
191 pub limit: Option<i64>,
195 #[derive(Serialize, Deserialize)]
196 pub struct ListRegistrationApplicationsResponse {
197 pub registration_applications: Vec<RegistrationApplicationView>,
200 #[derive(Serialize, Deserialize)]
201 pub struct ApproveRegistrationApplication {
204 pub deny_reason: Option<String>,
208 #[derive(Serialize, Deserialize)]
209 pub struct RegistrationApplicationResponse {
210 pub registration_application: RegistrationApplicationView,
213 #[derive(Serialize, Deserialize)]
214 pub struct GetUnreadRegistrationApplicationCount {
218 #[derive(Serialize, Deserialize, Clone)]
219 pub struct GetUnreadRegistrationApplicationCountResponse {
220 pub registration_applications: i64,