]> Untitled Git - lemmy.git/blob - crates/api_common/src/site.rs
Add creator id to search. Fixes #765
[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 creator_id: Option<PersonId>,
29   pub sort: String,
30   pub page: Option<i64>,
31   pub limit: Option<i64>,
32   pub auth: Option<String>,
33 }
34
35 #[derive(Serialize, Debug)]
36 pub struct SearchResponse {
37   pub type_: String,
38   pub comments: Vec<CommentView>,
39   pub posts: Vec<PostView>,
40   pub communities: Vec<CommunityView>,
41   pub users: Vec<PersonViewSafe>,
42 }
43
44 #[derive(Deserialize)]
45 pub struct GetModlog {
46   pub mod_person_id: Option<PersonId>,
47   pub community_id: Option<CommunityId>,
48   pub page: Option<i64>,
49   pub limit: Option<i64>,
50 }
51
52 #[derive(Serialize)]
53 pub struct GetModlogResponse {
54   pub removed_posts: Vec<ModRemovePostView>,
55   pub locked_posts: Vec<ModLockPostView>,
56   pub stickied_posts: Vec<ModStickyPostView>,
57   pub removed_comments: Vec<ModRemoveCommentView>,
58   pub removed_communities: Vec<ModRemoveCommunityView>,
59   pub banned_from_community: Vec<ModBanFromCommunityView>,
60   pub banned: Vec<ModBanView>,
61   pub added_to_community: Vec<ModAddCommunityView>,
62   pub added: Vec<ModAddView>,
63 }
64
65 #[derive(Deserialize)]
66 pub struct CreateSite {
67   pub name: String,
68   pub sidebar: Option<String>,
69   pub description: Option<String>,
70   pub icon: Option<String>,
71   pub banner: Option<String>,
72   pub enable_downvotes: bool,
73   pub open_registration: bool,
74   pub enable_nsfw: bool,
75   pub community_creation_admin_only: bool,
76   pub auth: String,
77 }
78
79 #[derive(Deserialize)]
80 pub struct EditSite {
81   pub name: String,
82   pub sidebar: Option<String>,
83   pub description: Option<String>,
84   pub icon: Option<String>,
85   pub banner: Option<String>,
86   pub enable_downvotes: bool,
87   pub open_registration: bool,
88   pub enable_nsfw: bool,
89   pub community_creation_admin_only: Option<bool>,
90   pub auth: String,
91 }
92
93 #[derive(Deserialize)]
94 pub struct GetSite {
95   pub auth: Option<String>,
96 }
97
98 #[derive(Serialize, Clone)]
99 pub struct SiteResponse {
100   pub site_view: SiteView,
101 }
102
103 #[derive(Serialize)]
104 pub struct GetSiteResponse {
105   pub site_view: Option<SiteView>, // Because the site might not be set up yet
106   pub admins: Vec<PersonViewSafe>,
107   pub banned: Vec<PersonViewSafe>,
108   pub online: usize,
109   pub version: String,
110   pub my_user: Option<LocalUserSettingsView>,
111   pub federated_instances: Option<FederatedInstances>, // Federation may be disabled
112 }
113
114 #[derive(Deserialize)]
115 pub struct TransferSite {
116   pub person_id: PersonId,
117   pub auth: String,
118 }
119
120 #[derive(Deserialize)]
121 pub struct GetSiteConfig {
122   pub auth: String,
123 }
124
125 #[derive(Serialize)]
126 pub struct GetSiteConfigResponse {
127   pub config_hjson: String,
128 }
129
130 #[derive(Deserialize)]
131 pub struct SaveSiteConfig {
132   pub config_hjson: String,
133   pub auth: String,
134 }
135
136 #[derive(Serialize)]
137 pub struct FederatedInstances {
138   pub linked: Vec<String>,
139   pub allowed: Option<Vec<String>>,
140   pub blocked: Option<Vec<String>>,
141 }