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