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