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