]> Untitled Git - lemmy.git/blob - crates/api_structs/src/community.rs
Rename `lemmy_structs` to `lemmy_api_structs`
[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 category_id: i32,
31   pub nsfw: bool,
32   pub auth: String,
33 }
34
35 #[derive(Serialize, Clone)]
36 pub struct CommunityResponse {
37   pub community_view: CommunityView,
38 }
39
40 #[derive(Deserialize, Debug)]
41 pub struct ListCommunities {
42   pub type_: String,
43   pub sort: String,
44   pub page: Option<i64>,
45   pub limit: Option<i64>,
46   pub auth: Option<String>,
47 }
48
49 #[derive(Serialize, Debug)]
50 pub struct ListCommunitiesResponse {
51   pub communities: Vec<CommunityView>,
52 }
53
54 #[derive(Deserialize, Clone)]
55 pub struct BanFromCommunity {
56   pub community_id: i32,
57   pub user_id: i32,
58   pub ban: bool,
59   pub remove_data: bool,
60   pub reason: Option<String>,
61   pub expires: Option<i64>,
62   pub auth: String,
63 }
64
65 #[derive(Serialize, Clone)]
66 pub struct BanFromCommunityResponse {
67   pub user_view: UserViewSafe,
68   pub banned: bool,
69 }
70
71 #[derive(Deserialize)]
72 pub struct AddModToCommunity {
73   pub community_id: i32,
74   pub user_id: i32,
75   pub added: bool,
76   pub auth: String,
77 }
78
79 #[derive(Serialize, Clone)]
80 pub struct AddModToCommunityResponse {
81   pub moderators: Vec<CommunityModeratorView>,
82 }
83
84 #[derive(Deserialize)]
85 pub struct EditCommunity {
86   pub community_id: i32,
87   pub title: String,
88   pub description: Option<String>,
89   pub icon: Option<String>,
90   pub banner: Option<String>,
91   pub category_id: i32,
92   pub nsfw: bool,
93   pub auth: String,
94 }
95
96 #[derive(Deserialize)]
97 pub struct DeleteCommunity {
98   pub community_id: i32,
99   pub deleted: bool,
100   pub auth: String,
101 }
102
103 #[derive(Deserialize)]
104 pub struct RemoveCommunity {
105   pub community_id: i32,
106   pub removed: bool,
107   pub reason: Option<String>,
108   pub expires: Option<i64>,
109   pub auth: String,
110 }
111
112 #[derive(Deserialize)]
113 pub struct FollowCommunity {
114   pub community_id: i32,
115   pub follow: bool,
116   pub auth: String,
117 }
118
119 #[derive(Deserialize)]
120 pub struct GetFollowedCommunities {
121   pub auth: String,
122 }
123
124 #[derive(Serialize)]
125 pub struct GetFollowedCommunitiesResponse {
126   pub communities: Vec<CommunityFollowerView>,
127 }
128
129 #[derive(Deserialize)]
130 pub struct TransferCommunity {
131   pub community_id: i32,
132   pub user_id: i32,
133   pub auth: String,
134 }