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