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