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