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