]> Untitled Git - lemmy.git/blob - crates/api_structs/src/community.rs
Remove extra category_id s . Fixes #1429
[lemmy.git] / crates / api_structs / src / community.rs
1 use lemmy_db_views_actor::{
2   community_follower_view::CommunityFollowerView,
3   community_moderator_view::CommunityModeratorView,
4   community_view::CommunityView,
5   user_view::UserViewSafe,
6 };
7 use serde::{Deserialize, Serialize};
8
9 #[derive(Deserialize)]
10 pub struct GetCommunity {
11   pub id: Option<i32>,
12   pub name: Option<String>,
13   pub auth: Option<String>,
14 }
15
16 #[derive(Serialize)]
17 pub struct GetCommunityResponse {
18   pub community_view: CommunityView,
19   pub moderators: Vec<CommunityModeratorView>,
20   pub online: usize,
21 }
22
23 #[derive(Deserialize)]
24 pub struct CreateCommunity {
25   pub name: String,
26   pub title: String,
27   pub description: Option<String>,
28   pub icon: Option<String>,
29   pub banner: Option<String>,
30   pub nsfw: bool,
31   pub auth: String,
32 }
33
34 #[derive(Serialize, Clone)]
35 pub struct CommunityResponse {
36   pub community_view: CommunityView,
37 }
38
39 #[derive(Deserialize, Debug)]
40 pub struct ListCommunities {
41   pub type_: String,
42   pub sort: String,
43   pub page: Option<i64>,
44   pub limit: Option<i64>,
45   pub auth: Option<String>,
46 }
47
48 #[derive(Serialize, Debug)]
49 pub struct ListCommunitiesResponse {
50   pub communities: Vec<CommunityView>,
51 }
52
53 #[derive(Deserialize, Clone)]
54 pub struct BanFromCommunity {
55   pub community_id: i32,
56   pub user_id: i32,
57   pub ban: bool,
58   pub remove_data: bool,
59   pub reason: Option<String>,
60   pub expires: Option<i64>,
61   pub auth: String,
62 }
63
64 #[derive(Serialize, Clone)]
65 pub struct BanFromCommunityResponse {
66   pub user_view: UserViewSafe,
67   pub banned: bool,
68 }
69
70 #[derive(Deserialize)]
71 pub struct AddModToCommunity {
72   pub community_id: i32,
73   pub user_id: i32,
74   pub added: bool,
75   pub auth: String,
76 }
77
78 #[derive(Serialize, Clone)]
79 pub struct AddModToCommunityResponse {
80   pub moderators: Vec<CommunityModeratorView>,
81 }
82
83 #[derive(Deserialize)]
84 pub struct EditCommunity {
85   pub community_id: i32,
86   pub title: String,
87   pub description: Option<String>,
88   pub icon: Option<String>,
89   pub banner: Option<String>,
90   pub nsfw: bool,
91   pub auth: String,
92 }
93
94 #[derive(Deserialize)]
95 pub struct DeleteCommunity {
96   pub community_id: i32,
97   pub deleted: bool,
98   pub auth: String,
99 }
100
101 #[derive(Deserialize)]
102 pub struct RemoveCommunity {
103   pub community_id: i32,
104   pub removed: bool,
105   pub reason: Option<String>,
106   pub expires: Option<i64>,
107   pub auth: String,
108 }
109
110 #[derive(Deserialize)]
111 pub struct FollowCommunity {
112   pub community_id: i32,
113   pub follow: bool,
114   pub auth: String,
115 }
116
117 #[derive(Deserialize)]
118 pub struct GetFollowedCommunities {
119   pub auth: String,
120 }
121
122 #[derive(Serialize)]
123 pub struct GetFollowedCommunitiesResponse {
124   pub communities: Vec<CommunityFollowerView>,
125 }
126
127 #[derive(Deserialize)]
128 pub struct TransferCommunity {
129   pub community_id: i32,
130   pub user_id: i32,
131   pub auth: String,
132 }