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