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