]> Untitled Git - lemmy.git/blob - crates/api_common/src/community.rs
Add restricted community field to CreateCommunity, UpdateCommunity (ref #2235) (...
[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 posting_restricted_to_mods: Option<bool>,
38   pub auth: Sensitive<String>,
39 }
40
41 #[derive(Debug, Serialize, Deserialize, Clone)]
42 pub struct CommunityResponse {
43   pub community_view: CommunityView,
44 }
45
46 #[derive(Serialize, Deserialize, Debug)]
47 pub struct ListCommunities {
48   pub type_: Option<String>,
49   pub sort: Option<String>,
50   pub page: Option<i64>,
51   pub limit: Option<i64>,
52   pub auth: Option<Sensitive<String>>,
53 }
54
55 #[derive(Serialize, Deserialize, Debug)]
56 pub struct ListCommunitiesResponse {
57   pub communities: Vec<CommunityView>,
58 }
59
60 #[derive(Debug, Serialize, Deserialize, Clone)]
61 pub struct BanFromCommunity {
62   pub community_id: CommunityId,
63   pub person_id: PersonId,
64   pub ban: bool,
65   pub remove_data: Option<bool>,
66   pub reason: Option<String>,
67   pub expires: Option<i64>,
68   pub auth: Sensitive<String>,
69 }
70
71 #[derive(Debug, Serialize, Deserialize, Clone)]
72 pub struct BanFromCommunityResponse {
73   pub person_view: PersonViewSafe,
74   pub banned: bool,
75 }
76
77 #[derive(Debug, Serialize, Deserialize)]
78 pub struct AddModToCommunity {
79   pub community_id: CommunityId,
80   pub person_id: PersonId,
81   pub added: bool,
82   pub auth: Sensitive<String>,
83 }
84
85 #[derive(Debug, Serialize, Deserialize, Clone)]
86 pub struct AddModToCommunityResponse {
87   pub moderators: Vec<CommunityModeratorView>,
88 }
89
90 #[derive(Debug, Serialize, Deserialize)]
91 pub struct EditCommunity {
92   pub community_id: CommunityId,
93   pub title: Option<String>,
94   pub description: Option<String>,
95   pub icon: Option<String>,
96   pub banner: Option<String>,
97   pub nsfw: Option<bool>,
98   pub posting_restricted_to_mods: Option<bool>,
99   pub auth: Sensitive<String>,
100 }
101
102 #[derive(Debug, Serialize, Deserialize)]
103 pub struct HideCommunity {
104   pub community_id: CommunityId,
105   pub hidden: bool,
106   pub reason: Option<String>,
107   pub auth: Sensitive<String>,
108 }
109
110 #[derive(Debug, Serialize, Deserialize)]
111 pub struct DeleteCommunity {
112   pub community_id: CommunityId,
113   pub deleted: bool,
114   pub auth: Sensitive<String>,
115 }
116
117 #[derive(Debug, Serialize, Deserialize)]
118 pub struct RemoveCommunity {
119   pub community_id: CommunityId,
120   pub removed: bool,
121   pub reason: Option<String>,
122   pub expires: Option<i64>,
123   pub auth: Sensitive<String>,
124 }
125
126 #[derive(Debug, Serialize, Deserialize)]
127 pub struct FollowCommunity {
128   pub community_id: CommunityId,
129   pub follow: bool,
130   pub auth: Sensitive<String>,
131 }
132
133 #[derive(Debug, Serialize, Deserialize)]
134 pub struct BlockCommunity {
135   pub community_id: CommunityId,
136   pub block: bool,
137   pub auth: Sensitive<String>,
138 }
139
140 #[derive(Debug, Serialize, Deserialize, Clone)]
141 pub struct BlockCommunityResponse {
142   pub community_view: CommunityView,
143   pub blocked: bool,
144 }
145
146 #[derive(Debug, Serialize, Deserialize)]
147 pub struct TransferCommunity {
148   pub community_id: CommunityId,
149   pub person_id: PersonId,
150   pub auth: Sensitive<String>,
151 }