1 use crate::sensitive::Sensitive;
3 newtypes::{CommunityId, LanguageId, PersonId},
8 use lemmy_db_views_actor::structs::{CommunityModeratorView, CommunityView, PersonView};
9 use serde::{Deserialize, Serialize};
10 use serde_with::skip_serializing_none;
11 #[cfg(feature = "full")]
14 #[skip_serializing_none]
15 #[derive(Debug, Serialize, Deserialize, Clone, Default)]
16 #[cfg_attr(feature = "full", derive(TS))]
17 #[cfg_attr(feature = "full", ts(export))]
18 pub struct GetCommunity {
19 pub id: Option<CommunityId>,
20 /// Example: star_trek , or star_trek@xyz.tld
21 pub name: Option<String>,
22 pub auth: Option<Sensitive<String>>,
25 #[skip_serializing_none]
26 #[derive(Debug, Serialize, Deserialize, Clone)]
27 #[cfg_attr(feature = "full", derive(TS))]
28 #[cfg_attr(feature = "full", ts(export))]
29 pub struct GetCommunityResponse {
30 pub community_view: CommunityView,
31 pub site: Option<Site>,
32 pub moderators: Vec<CommunityModeratorView>,
34 pub discussion_languages: Vec<LanguageId>,
35 /// Default language used for new posts if none is specified, generated based on community and
37 pub default_post_language: Option<LanguageId>,
40 #[skip_serializing_none]
41 #[cfg_attr(feature = "full", derive(TS))]
42 #[cfg_attr(feature = "full", ts(export))]
43 #[derive(Debug, Serialize, Deserialize, Clone, Default)]
44 pub struct CreateCommunity {
47 pub description: Option<String>,
48 pub icon: Option<String>,
49 pub banner: Option<String>,
50 pub nsfw: Option<bool>,
51 pub posting_restricted_to_mods: Option<bool>,
52 pub discussion_languages: Option<Vec<LanguageId>>,
53 pub auth: Sensitive<String>,
56 #[derive(Debug, Serialize, Deserialize, Clone)]
57 #[cfg_attr(feature = "full", derive(TS))]
58 #[cfg_attr(feature = "full", ts(export))]
59 pub struct CommunityResponse {
60 pub community_view: CommunityView,
61 pub discussion_languages: Vec<LanguageId>,
64 #[skip_serializing_none]
65 #[derive(Debug, Serialize, Deserialize, Clone, Default)]
66 #[cfg_attr(feature = "full", derive(TS))]
67 #[cfg_attr(feature = "full", ts(export))]
68 pub struct ListCommunities {
69 pub type_: Option<ListingType>,
70 pub sort: Option<SortType>,
71 pub page: Option<i64>,
72 pub limit: Option<i64>,
73 pub auth: Option<Sensitive<String>>,
76 #[derive(Debug, Serialize, Deserialize, Clone)]
77 #[cfg_attr(feature = "full", derive(TS))]
78 #[cfg_attr(feature = "full", ts(export))]
79 pub struct ListCommunitiesResponse {
80 pub communities: Vec<CommunityView>,
83 #[skip_serializing_none]
84 #[derive(Debug, Serialize, Deserialize, Clone, Default)]
85 #[cfg_attr(feature = "full", derive(TS))]
86 #[cfg_attr(feature = "full", ts(export))]
87 pub struct BanFromCommunity {
88 pub community_id: CommunityId,
89 pub person_id: PersonId,
91 pub remove_data: Option<bool>,
92 pub reason: Option<String>,
93 pub expires: Option<i64>,
94 pub auth: Sensitive<String>,
97 #[derive(Debug, Serialize, Deserialize, Clone)]
98 #[cfg_attr(feature = "full", derive(TS))]
99 #[cfg_attr(feature = "full", ts(export))]
100 pub struct BanFromCommunityResponse {
101 pub person_view: PersonView,
105 #[derive(Debug, Serialize, Deserialize, Clone, Default)]
106 #[cfg_attr(feature = "full", derive(TS))]
107 #[cfg_attr(feature = "full", ts(export))]
108 pub struct AddModToCommunity {
109 pub community_id: CommunityId,
110 pub person_id: PersonId,
112 pub auth: Sensitive<String>,
115 #[derive(Debug, Serialize, Deserialize, Clone)]
116 #[cfg_attr(feature = "full", derive(TS))]
117 #[cfg_attr(feature = "full", ts(export))]
118 pub struct AddModToCommunityResponse {
119 pub moderators: Vec<CommunityModeratorView>,
122 #[skip_serializing_none]
123 #[derive(Debug, Serialize, Deserialize, Clone, Default)]
124 #[cfg_attr(feature = "full", derive(TS))]
125 #[cfg_attr(feature = "full", ts(export))]
126 pub struct EditCommunity {
127 pub community_id: CommunityId,
128 pub title: Option<String>,
129 pub description: Option<String>,
130 pub icon: Option<String>,
131 pub banner: Option<String>,
132 pub nsfw: Option<bool>,
133 pub posting_restricted_to_mods: Option<bool>,
134 pub discussion_languages: Option<Vec<LanguageId>>,
135 pub auth: Sensitive<String>,
138 #[skip_serializing_none]
139 #[derive(Debug, Serialize, Deserialize, Clone, Default)]
140 #[cfg_attr(feature = "full", derive(TS))]
141 #[cfg_attr(feature = "full", ts(export))]
142 pub struct HideCommunity {
143 pub community_id: CommunityId,
145 pub reason: Option<String>,
146 pub auth: Sensitive<String>,
149 #[skip_serializing_none]
150 #[derive(Debug, Serialize, Deserialize, Clone, Default)]
151 #[cfg_attr(feature = "full", derive(TS))]
152 #[cfg_attr(feature = "full", ts(export))]
153 pub struct DeleteCommunity {
154 pub community_id: CommunityId,
156 pub auth: Sensitive<String>,
159 #[skip_serializing_none]
160 #[derive(Debug, Serialize, Deserialize, Clone, Default)]
161 #[cfg_attr(feature = "full", derive(TS))]
162 #[cfg_attr(feature = "full", ts(export))]
163 pub struct RemoveCommunity {
164 pub community_id: CommunityId,
166 pub reason: Option<String>,
167 pub expires: Option<i64>,
168 pub auth: Sensitive<String>,
171 #[derive(Debug, Serialize, Deserialize, Clone, Default)]
172 #[cfg_attr(feature = "full", derive(TS))]
173 #[cfg_attr(feature = "full", ts(export))]
174 pub struct FollowCommunity {
175 pub community_id: CommunityId,
177 pub auth: Sensitive<String>,
180 #[derive(Debug, Serialize, Deserialize, Clone, Default)]
181 #[cfg_attr(feature = "full", derive(TS))]
182 #[cfg_attr(feature = "full", ts(export))]
183 pub struct BlockCommunity {
184 pub community_id: CommunityId,
186 pub auth: Sensitive<String>,
189 #[skip_serializing_none]
190 #[derive(Debug, Serialize, Deserialize, Clone)]
191 #[cfg_attr(feature = "full", derive(TS))]
192 #[cfg_attr(feature = "full", ts(export))]
193 pub struct BlockCommunityResponse {
194 pub community_view: CommunityView,
198 #[derive(Debug, Serialize, Deserialize, Clone, Default)]
199 #[cfg_attr(feature = "full", derive(TS))]
200 #[cfg_attr(feature = "full", ts(export))]
201 pub struct TransferCommunity {
202 pub community_id: CommunityId,
203 pub person_id: PersonId,
204 pub auth: Sensitive<String>,