]> Untitled Git - lemmy.git/blob - crates/api_common/src/site.rs
Adding a short site description. Fixes #1496 (#1532)
[lemmy.git] / crates / api_common / src / site.rs
1 use lemmy_db_schema::{CommunityId, PersonId};
2 use lemmy_db_views::{
3   comment_view::CommentView,
4   local_user_view::LocalUserSettingsView,
5   post_view::PostView,
6   site_view::SiteView,
7 };
8 use lemmy_db_views_actor::{community_view::CommunityView, person_view::PersonViewSafe};
9 use lemmy_db_views_moderator::{
10   mod_add_community_view::ModAddCommunityView,
11   mod_add_view::ModAddView,
12   mod_ban_from_community_view::ModBanFromCommunityView,
13   mod_ban_view::ModBanView,
14   mod_lock_post_view::ModLockPostView,
15   mod_remove_comment_view::ModRemoveCommentView,
16   mod_remove_community_view::ModRemoveCommunityView,
17   mod_remove_post_view::ModRemovePostView,
18   mod_sticky_post_view::ModStickyPostView,
19 };
20 use serde::{Deserialize, Serialize};
21
22 #[derive(Deserialize, Debug)]
23 pub struct Search {
24   pub q: String,
25   pub type_: String,
26   pub community_id: Option<CommunityId>,
27   pub community_name: Option<String>,
28   pub sort: String,
29   pub page: Option<i64>,
30   pub limit: Option<i64>,
31   pub auth: Option<String>,
32 }
33
34 #[derive(Serialize, Debug)]
35 pub struct SearchResponse {
36   pub type_: String,
37   pub comments: Vec<CommentView>,
38   pub posts: Vec<PostView>,
39   pub communities: Vec<CommunityView>,
40   pub users: Vec<PersonViewSafe>,
41 }
42
43 #[derive(Deserialize)]
44 pub struct GetModlog {
45   pub mod_person_id: Option<PersonId>,
46   pub community_id: Option<CommunityId>,
47   pub page: Option<i64>,
48   pub limit: Option<i64>,
49 }
50
51 #[derive(Serialize)]
52 pub struct GetModlogResponse {
53   pub removed_posts: Vec<ModRemovePostView>,
54   pub locked_posts: Vec<ModLockPostView>,
55   pub stickied_posts: Vec<ModStickyPostView>,
56   pub removed_comments: Vec<ModRemoveCommentView>,
57   pub removed_communities: Vec<ModRemoveCommunityView>,
58   pub banned_from_community: Vec<ModBanFromCommunityView>,
59   pub banned: Vec<ModBanView>,
60   pub added_to_community: Vec<ModAddCommunityView>,
61   pub added: Vec<ModAddView>,
62 }
63
64 #[derive(Deserialize)]
65 pub struct CreateSite {
66   pub name: String,
67   pub sidebar: Option<String>,
68   pub description: Option<String>,
69   pub icon: Option<String>,
70   pub banner: Option<String>,
71   pub enable_downvotes: bool,
72   pub open_registration: bool,
73   pub enable_nsfw: bool,
74   pub auth: String,
75 }
76
77 #[derive(Deserialize)]
78 pub struct EditSite {
79   pub name: String,
80   pub sidebar: Option<String>,
81   pub description: Option<String>,
82   pub icon: Option<String>,
83   pub banner: Option<String>,
84   pub enable_downvotes: bool,
85   pub open_registration: bool,
86   pub enable_nsfw: bool,
87   pub auth: String,
88 }
89
90 #[derive(Deserialize)]
91 pub struct GetSite {
92   pub auth: Option<String>,
93 }
94
95 #[derive(Serialize, Clone)]
96 pub struct SiteResponse {
97   pub site_view: SiteView,
98 }
99
100 #[derive(Serialize)]
101 pub struct GetSiteResponse {
102   pub site_view: Option<SiteView>, // Because the site might not be set up yet
103   pub admins: Vec<PersonViewSafe>,
104   pub banned: Vec<PersonViewSafe>,
105   pub online: usize,
106   pub version: String,
107   pub my_user: Option<LocalUserSettingsView>,
108   pub federated_instances: Option<FederatedInstances>, // Federation may be disabled
109 }
110
111 #[derive(Deserialize)]
112 pub struct TransferSite {
113   pub person_id: PersonId,
114   pub auth: String,
115 }
116
117 #[derive(Deserialize)]
118 pub struct GetSiteConfig {
119   pub auth: String,
120 }
121
122 #[derive(Serialize)]
123 pub struct GetSiteConfigResponse {
124   pub config_hjson: String,
125 }
126
127 #[derive(Deserialize)]
128 pub struct SaveSiteConfig {
129   pub config_hjson: String,
130   pub auth: String,
131 }
132
133 #[derive(Serialize)]
134 pub struct FederatedInstances {
135   pub linked: Vec<String>,
136   pub allowed: Option<Vec<String>>,
137   pub blocked: Option<Vec<String>>,
138 }