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