]> Untitled Git - lemmy.git/blob - crates/api_structs/src/community.rs
Fixing image locations.
[lemmy.git] / crates / api_structs / src / community.rs
1 use lemmy_db_schema::{CommunityId, PersonId};
2 use lemmy_db_views_actor::{
3   community_follower_view::CommunityFollowerView,
4   community_moderator_view::CommunityModeratorView,
5   community_view::CommunityView,
6   person_view::PersonViewSafe,
7 };
8 use serde::{Deserialize, Serialize};
9
10 #[derive(Deserialize)]
11 pub struct GetCommunity {
12   pub id: Option<CommunityId>,
13   pub name: Option<String>,
14   pub auth: Option<String>,
15 }
16
17 #[derive(Serialize)]
18 pub struct GetCommunityResponse {
19   pub community_view: CommunityView,
20   pub moderators: Vec<CommunityModeratorView>,
21   pub online: usize,
22 }
23
24 #[derive(Deserialize)]
25 pub struct CreateCommunity {
26   pub name: String,
27   pub title: String,
28   pub description: Option<String>,
29   pub icon: Option<String>,
30   pub banner: Option<String>,
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: CommunityId,
57   pub person_id: PersonId,
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 person_view: PersonViewSafe,
68   pub banned: bool,
69 }
70
71 #[derive(Deserialize)]
72 pub struct AddModToCommunity {
73   pub community_id: CommunityId,
74   pub person_id: PersonId,
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: CommunityId,
87   pub title: String,
88   pub description: Option<String>,
89   pub icon: Option<String>,
90   pub banner: Option<String>,
91   pub nsfw: bool,
92   pub auth: String,
93 }
94
95 #[derive(Deserialize)]
96 pub struct DeleteCommunity {
97   pub community_id: CommunityId,
98   pub deleted: bool,
99   pub auth: String,
100 }
101
102 #[derive(Deserialize)]
103 pub struct RemoveCommunity {
104   pub community_id: CommunityId,
105   pub removed: bool,
106   pub reason: Option<String>,
107   pub expires: Option<i64>,
108   pub auth: String,
109 }
110
111 #[derive(Deserialize)]
112 pub struct FollowCommunity {
113   pub community_id: CommunityId,
114   pub follow: bool,
115   pub auth: String,
116 }
117
118 #[derive(Deserialize)]
119 pub struct GetFollowedCommunities {
120   pub auth: String,
121 }
122
123 #[derive(Serialize)]
124 pub struct GetFollowedCommunitiesResponse {
125   pub communities: Vec<CommunityFollowerView>,
126 }
127
128 #[derive(Deserialize)]
129 pub struct TransferCommunity {
130   pub community_id: CommunityId,
131   pub person_id: PersonId,
132   pub auth: String,
133 }