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