]> Untitled Git - lemmy.git/blob - crates/api_common/src/site.rs
Add legal information (fixes #721) (#2273)
[lemmy.git] / crates / api_common / src / site.rs
1 use crate::sensitive::Sensitive;
2 use lemmy_db_schema::{
3   newtypes::{CommunityId, PersonId},
4   ListingType,
5   SearchType,
6   SortType,
7 };
8 use lemmy_db_views::structs::{
9   CommentView,
10   LocalUserSettingsView,
11   PostView,
12   RegistrationApplicationView,
13   SiteView,
14 };
15 use lemmy_db_views_actor::structs::{
16   CommunityBlockView,
17   CommunityFollowerView,
18   CommunityModeratorView,
19   CommunityView,
20   PersonBlockView,
21   PersonViewSafe,
22 };
23 use lemmy_db_views_moderator::structs::{
24   ModAddCommunityView,
25   ModAddView,
26   ModBanFromCommunityView,
27   ModBanView,
28   ModHideCommunityView,
29   ModLockPostView,
30   ModRemoveCommentView,
31   ModRemoveCommunityView,
32   ModRemovePostView,
33   ModStickyPostView,
34   ModTransferCommunityView,
35 };
36 use serde::{Deserialize, Serialize};
37
38 #[derive(Debug, Serialize, Deserialize, Clone, Default)]
39 pub struct Search {
40   pub q: String,
41   pub community_id: Option<CommunityId>,
42   pub community_name: Option<String>,
43   pub creator_id: Option<PersonId>,
44   pub type_: Option<SearchType>,
45   pub sort: Option<SortType>,
46   pub listing_type: Option<ListingType>,
47   pub page: Option<i64>,
48   pub limit: Option<i64>,
49   pub auth: Option<Sensitive<String>>,
50 }
51
52 #[derive(Debug, Serialize, Deserialize, Clone)]
53 pub struct SearchResponse {
54   pub type_: String,
55   pub comments: Vec<CommentView>,
56   pub posts: Vec<PostView>,
57   pub communities: Vec<CommunityView>,
58   pub users: Vec<PersonViewSafe>,
59 }
60
61 #[derive(Debug, Serialize, Deserialize, Clone, Default)]
62 pub struct ResolveObject {
63   pub q: String,
64   pub auth: Option<Sensitive<String>>,
65 }
66
67 #[derive(Debug, Serialize, Deserialize, Default)]
68 pub struct ResolveObjectResponse {
69   pub comment: Option<CommentView>,
70   pub post: Option<PostView>,
71   pub community: Option<CommunityView>,
72   pub person: Option<PersonViewSafe>,
73 }
74
75 #[derive(Debug, Serialize, Deserialize, Clone, Default)]
76 pub struct GetModlog {
77   pub mod_person_id: Option<PersonId>,
78   pub community_id: Option<CommunityId>,
79   pub page: Option<i64>,
80   pub limit: Option<i64>,
81   pub auth: Option<Sensitive<String>>,
82 }
83
84 #[derive(Debug, Serialize, Deserialize, Clone)]
85 pub struct GetModlogResponse {
86   pub removed_posts: Vec<ModRemovePostView>,
87   pub locked_posts: Vec<ModLockPostView>,
88   pub stickied_posts: Vec<ModStickyPostView>,
89   pub removed_comments: Vec<ModRemoveCommentView>,
90   pub removed_communities: Vec<ModRemoveCommunityView>,
91   pub banned_from_community: Vec<ModBanFromCommunityView>,
92   pub banned: Vec<ModBanView>,
93   pub added_to_community: Vec<ModAddCommunityView>,
94   pub transferred_to_community: Vec<ModTransferCommunityView>,
95   pub added: Vec<ModAddView>,
96   pub hidden_communities: Vec<ModHideCommunityView>,
97 }
98
99 #[derive(Debug, Serialize, Deserialize, Clone, Default)]
100 pub struct CreateSite {
101   pub name: String,
102   pub sidebar: Option<String>,
103   pub description: Option<String>,
104   pub icon: Option<String>,
105   pub banner: Option<String>,
106   pub enable_downvotes: Option<bool>,
107   pub open_registration: Option<bool>,
108   pub enable_nsfw: Option<bool>,
109   pub community_creation_admin_only: Option<bool>,
110   pub require_email_verification: Option<bool>,
111   pub require_application: Option<bool>,
112   pub application_question: Option<String>,
113   pub private_instance: Option<bool>,
114   pub default_theme: Option<String>,
115   pub default_post_listing_type: Option<String>,
116   pub auth: Sensitive<String>,
117 }
118
119 #[derive(Debug, Serialize, Deserialize, Clone, Default)]
120 pub struct EditSite {
121   pub name: Option<String>,
122   pub sidebar: Option<String>,
123   pub description: Option<String>,
124   pub icon: Option<String>,
125   pub banner: Option<String>,
126   pub enable_downvotes: Option<bool>,
127   pub open_registration: Option<bool>,
128   pub enable_nsfw: Option<bool>,
129   pub community_creation_admin_only: Option<bool>,
130   pub require_email_verification: Option<bool>,
131   pub require_application: Option<bool>,
132   pub application_question: Option<String>,
133   pub private_instance: Option<bool>,
134   pub default_theme: Option<String>,
135   pub default_post_listing_type: Option<String>,
136   pub legal_information: Option<String>,
137   pub auth: Sensitive<String>,
138 }
139
140 #[derive(Debug, Serialize, Deserialize, Clone, Default)]
141 pub struct GetSite {
142   pub auth: Option<Sensitive<String>>,
143 }
144
145 #[derive(Debug, Serialize, Deserialize, Clone)]
146 pub struct SiteResponse {
147   pub site_view: SiteView,
148 }
149
150 #[derive(Debug, Serialize, Deserialize, Clone)]
151 pub struct GetSiteResponse {
152   pub site_view: Option<SiteView>, // Because the site might not be set up yet
153   pub admins: Vec<PersonViewSafe>,
154   pub online: usize,
155   pub version: String,
156   pub my_user: Option<MyUserInfo>,
157   pub federated_instances: Option<FederatedInstances>, // Federation may be disabled
158 }
159
160 #[derive(Debug, Serialize, Deserialize, Clone)]
161 pub struct MyUserInfo {
162   pub local_user_view: LocalUserSettingsView,
163   pub follows: Vec<CommunityFollowerView>,
164   pub moderates: Vec<CommunityModeratorView>,
165   pub community_blocks: Vec<CommunityBlockView>,
166   pub person_blocks: Vec<PersonBlockView>,
167 }
168
169 #[derive(Debug, Serialize, Deserialize, Clone)]
170 pub struct LeaveAdmin {
171   pub auth: Sensitive<String>,
172 }
173
174 #[derive(Debug, Serialize, Deserialize, Clone)]
175 pub struct GetSiteConfig {
176   pub auth: Sensitive<String>,
177 }
178
179 #[derive(Debug, Serialize, Deserialize, Clone)]
180 pub struct GetSiteConfigResponse {
181   pub config_hjson: String,
182 }
183
184 #[derive(Debug, Serialize, Deserialize, Clone)]
185 pub struct SaveSiteConfig {
186   pub config_hjson: String,
187   pub auth: Sensitive<String>,
188 }
189
190 #[derive(Debug, Serialize, Deserialize, Clone)]
191 pub struct FederatedInstances {
192   pub linked: Vec<String>,
193   pub allowed: Option<Vec<String>>,
194   pub blocked: Option<Vec<String>>,
195 }
196
197 #[derive(Debug, Serialize, Deserialize, Clone, Default)]
198 pub struct ListRegistrationApplications {
199   /// Only shows the unread applications (IE those without an admin actor)
200   pub unread_only: Option<bool>,
201   pub page: Option<i64>,
202   pub limit: Option<i64>,
203   pub auth: String,
204 }
205
206 #[derive(Debug, Serialize, Deserialize, Clone)]
207 pub struct ListRegistrationApplicationsResponse {
208   pub registration_applications: Vec<RegistrationApplicationView>,
209 }
210
211 #[derive(Debug, Serialize, Deserialize, Clone, Default)]
212 pub struct ApproveRegistrationApplication {
213   pub id: i32,
214   pub approve: bool,
215   pub deny_reason: Option<String>,
216   pub auth: String,
217 }
218
219 #[derive(Debug, Serialize, Deserialize, Clone)]
220 pub struct RegistrationApplicationResponse {
221   pub registration_application: RegistrationApplicationView,
222 }
223
224 #[derive(Debug, Serialize, Deserialize, Clone)]
225 pub struct GetUnreadRegistrationApplicationCount {
226   pub auth: String,
227 }
228
229 #[derive(Debug, Serialize, Deserialize, Clone)]
230 pub struct GetUnreadRegistrationApplicationCountResponse {
231   pub registration_applications: i64,
232 }