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 /// Get a community. Must provide either an id, or a name.
19 pub struct GetCommunity {
20 pub id: Option<CommunityId>,
21 /// Example: star_trek , or star_trek@xyz.tld
22 pub name: Option<String>,
23 pub auth: Option<Sensitive<String>>,
26 #[skip_serializing_none]
27 #[derive(Debug, Serialize, Deserialize, Clone)]
28 #[cfg_attr(feature = "full", derive(TS))]
29 #[cfg_attr(feature = "full", ts(export))]
30 /// The community response.
31 pub struct GetCommunityResponse {
32 pub community_view: CommunityView,
33 pub site: Option<Site>,
34 pub moderators: Vec<CommunityModeratorView>,
35 pub discussion_languages: Vec<LanguageId>,
38 #[skip_serializing_none]
39 #[cfg_attr(feature = "full", derive(TS))]
40 #[cfg_attr(feature = "full", ts(export))]
41 #[derive(Debug, Serialize, Deserialize, Clone, Default)]
42 /// Create a community.
43 pub struct CreateCommunity {
48 /// A longer sidebar, or description of your community, in markdown.
49 pub description: Option<String>,
51 pub icon: Option<String>,
53 pub banner: Option<String>,
54 /// Whether its an NSFW community.
55 pub nsfw: Option<bool>,
56 /// Whether to restrict posting only to moderators.
57 pub posting_restricted_to_mods: Option<bool>,
58 pub discussion_languages: Option<Vec<LanguageId>>,
59 pub auth: Sensitive<String>,
62 #[derive(Debug, Serialize, Deserialize, Clone)]
63 #[cfg_attr(feature = "full", derive(TS))]
64 #[cfg_attr(feature = "full", ts(export))]
65 /// A simple community response.
66 pub struct CommunityResponse {
67 pub community_view: CommunityView,
68 pub discussion_languages: Vec<LanguageId>,
71 #[skip_serializing_none]
72 #[derive(Debug, Serialize, Deserialize, Clone, Default)]
73 #[cfg_attr(feature = "full", derive(TS))]
74 #[cfg_attr(feature = "full", ts(export))]
75 /// Fetches a list of communities.
76 pub struct ListCommunities {
77 pub type_: Option<ListingType>,
78 pub sort: Option<SortType>,
79 pub page: Option<i64>,
80 pub limit: Option<i64>,
81 pub auth: Option<Sensitive<String>>,
84 #[derive(Debug, Serialize, Deserialize, Clone)]
85 #[cfg_attr(feature = "full", derive(TS))]
86 #[cfg_attr(feature = "full", ts(export))]
87 /// The response for listing communities.
88 pub struct ListCommunitiesResponse {
89 pub communities: Vec<CommunityView>,
92 #[skip_serializing_none]
93 #[derive(Debug, Serialize, Deserialize, Clone, Default)]
94 #[cfg_attr(feature = "full", derive(TS))]
95 #[cfg_attr(feature = "full", ts(export))]
96 /// Ban a user from a community.
97 pub struct BanFromCommunity {
98 pub community_id: CommunityId,
99 pub person_id: PersonId,
101 pub remove_data: Option<bool>,
102 pub reason: Option<String>,
103 pub expires: Option<i64>,
104 pub auth: Sensitive<String>,
107 #[derive(Debug, Serialize, Deserialize, Clone)]
108 #[cfg_attr(feature = "full", derive(TS))]
109 #[cfg_attr(feature = "full", ts(export))]
110 /// The response for banning a user from a community.
111 pub struct BanFromCommunityResponse {
112 pub person_view: PersonView,
116 #[derive(Debug, Serialize, Deserialize, Clone, Default)]
117 #[cfg_attr(feature = "full", derive(TS))]
118 #[cfg_attr(feature = "full", ts(export))]
119 /// Add a moderator to a community.
120 pub struct AddModToCommunity {
121 pub community_id: CommunityId,
122 pub person_id: PersonId,
124 pub auth: Sensitive<String>,
127 #[derive(Debug, Serialize, Deserialize, Clone)]
128 #[cfg_attr(feature = "full", derive(TS))]
129 #[cfg_attr(feature = "full", ts(export))]
130 /// The response of adding a moderator to a community.
131 pub struct AddModToCommunityResponse {
132 pub moderators: Vec<CommunityModeratorView>,
135 #[skip_serializing_none]
136 #[derive(Debug, Serialize, Deserialize, Clone, Default)]
137 #[cfg_attr(feature = "full", derive(TS))]
138 #[cfg_attr(feature = "full", ts(export))]
139 /// Edit a community.
140 pub struct EditCommunity {
141 pub community_id: CommunityId,
143 pub title: Option<String>,
144 /// A longer sidebar, or description of your community, in markdown.
145 pub description: Option<String>,
147 pub icon: Option<String>,
149 pub banner: Option<String>,
150 /// Whether its an NSFW community.
151 pub nsfw: Option<bool>,
152 /// Whether to restrict posting only to moderators.
153 pub posting_restricted_to_mods: Option<bool>,
154 pub discussion_languages: Option<Vec<LanguageId>>,
155 pub auth: Sensitive<String>,
158 #[skip_serializing_none]
159 #[derive(Debug, Serialize, Deserialize, Clone, Default)]
160 #[cfg_attr(feature = "full", derive(TS))]
161 #[cfg_attr(feature = "full", ts(export))]
162 /// Hide a community from the main view.
163 // TODO this should really be a part of edit community. And why does it contain a reason, that should be in the mod tables.
164 pub struct HideCommunity {
165 pub community_id: CommunityId,
167 pub reason: Option<String>,
168 pub auth: Sensitive<String>,
171 #[skip_serializing_none]
172 #[derive(Debug, Serialize, Deserialize, Clone, Default)]
173 #[cfg_attr(feature = "full", derive(TS))]
174 #[cfg_attr(feature = "full", ts(export))]
175 /// Delete your own community.
176 pub struct DeleteCommunity {
177 pub community_id: CommunityId,
179 pub auth: Sensitive<String>,
182 #[skip_serializing_none]
183 #[derive(Debug, Serialize, Deserialize, Clone, Default)]
184 #[cfg_attr(feature = "full", derive(TS))]
185 #[cfg_attr(feature = "full", ts(export))]
186 /// Remove a community (only doable by moderators).
187 pub struct RemoveCommunity {
188 pub community_id: CommunityId,
190 pub reason: Option<String>,
191 pub expires: Option<i64>,
192 pub auth: Sensitive<String>,
195 #[derive(Debug, Serialize, Deserialize, Clone, Default)]
196 #[cfg_attr(feature = "full", derive(TS))]
197 #[cfg_attr(feature = "full", ts(export))]
198 /// Follow / subscribe to a community.
199 pub struct FollowCommunity {
200 pub community_id: CommunityId,
202 pub auth: Sensitive<String>,
205 #[derive(Debug, Serialize, Deserialize, Clone, Default)]
206 #[cfg_attr(feature = "full", derive(TS))]
207 #[cfg_attr(feature = "full", ts(export))]
208 /// Block a community.
209 pub struct BlockCommunity {
210 pub community_id: CommunityId,
212 pub auth: Sensitive<String>,
215 #[skip_serializing_none]
216 #[derive(Debug, Serialize, Deserialize, Clone)]
217 #[cfg_attr(feature = "full", derive(TS))]
218 #[cfg_attr(feature = "full", ts(export))]
219 /// The block community response.
220 pub struct BlockCommunityResponse {
221 pub community_view: CommunityView,
225 #[derive(Debug, Serialize, Deserialize, Clone, Default)]
226 #[cfg_attr(feature = "full", derive(TS))]
227 #[cfg_attr(feature = "full", ts(export))]
228 /// Transfer a community to a new owner.
229 pub struct TransferCommunity {
230 pub community_id: CommunityId,
231 pub person_id: PersonId,
232 pub auth: Sensitive<String>,