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>,
36 pub discussion_languages: Vec<LanguageId>,
39 #[skip_serializing_none]
40 #[cfg_attr(feature = "full", derive(TS))]
41 #[cfg_attr(feature = "full", ts(export))]
42 #[derive(Debug, Serialize, Deserialize, Clone, Default)]
43 /// Create a community.
44 pub struct CreateCommunity {
49 /// A longer sidebar, or description of your community, in markdown.
50 pub description: Option<String>,
52 pub icon: Option<String>,
54 pub banner: Option<String>,
55 /// Whether its an NSFW community.
56 pub nsfw: Option<bool>,
57 /// Whether to restrict posting only to moderators.
58 pub posting_restricted_to_mods: Option<bool>,
59 pub discussion_languages: Option<Vec<LanguageId>>,
60 pub auth: Sensitive<String>,
63 #[derive(Debug, Serialize, Deserialize, Clone)]
64 #[cfg_attr(feature = "full", derive(TS))]
65 #[cfg_attr(feature = "full", ts(export))]
66 /// A simple community response.
67 pub struct CommunityResponse {
68 pub community_view: CommunityView,
69 pub discussion_languages: Vec<LanguageId>,
72 #[skip_serializing_none]
73 #[derive(Debug, Serialize, Deserialize, Clone, Default)]
74 #[cfg_attr(feature = "full", derive(TS))]
75 #[cfg_attr(feature = "full", ts(export))]
76 /// Fetches a list of communities.
77 pub struct ListCommunities {
78 pub type_: Option<ListingType>,
79 pub sort: Option<SortType>,
80 pub page: Option<i64>,
81 pub limit: Option<i64>,
82 pub auth: Option<Sensitive<String>>,
85 #[derive(Debug, Serialize, Deserialize, Clone)]
86 #[cfg_attr(feature = "full", derive(TS))]
87 #[cfg_attr(feature = "full", ts(export))]
88 /// The response for listing communities.
89 pub struct ListCommunitiesResponse {
90 pub communities: Vec<CommunityView>,
93 #[skip_serializing_none]
94 #[derive(Debug, Serialize, Deserialize, Clone, Default)]
95 #[cfg_attr(feature = "full", derive(TS))]
96 #[cfg_attr(feature = "full", ts(export))]
97 /// Ban a user from a community.
98 pub struct BanFromCommunity {
99 pub community_id: CommunityId,
100 pub person_id: PersonId,
102 pub remove_data: Option<bool>,
103 pub reason: Option<String>,
104 pub expires: Option<i64>,
105 pub auth: Sensitive<String>,
108 #[derive(Debug, Serialize, Deserialize, Clone)]
109 #[cfg_attr(feature = "full", derive(TS))]
110 #[cfg_attr(feature = "full", ts(export))]
111 /// The response for banning a user from a community.
112 pub struct BanFromCommunityResponse {
113 pub person_view: PersonView,
117 #[derive(Debug, Serialize, Deserialize, Clone, Default)]
118 #[cfg_attr(feature = "full", derive(TS))]
119 #[cfg_attr(feature = "full", ts(export))]
120 /// Add a moderator to a community.
121 pub struct AddModToCommunity {
122 pub community_id: CommunityId,
123 pub person_id: PersonId,
125 pub auth: Sensitive<String>,
128 #[derive(Debug, Serialize, Deserialize, Clone)]
129 #[cfg_attr(feature = "full", derive(TS))]
130 #[cfg_attr(feature = "full", ts(export))]
131 /// The response of adding a moderator to a community.
132 pub struct AddModToCommunityResponse {
133 pub moderators: Vec<CommunityModeratorView>,
136 #[skip_serializing_none]
137 #[derive(Debug, Serialize, Deserialize, Clone, Default)]
138 #[cfg_attr(feature = "full", derive(TS))]
139 #[cfg_attr(feature = "full", ts(export))]
140 /// Edit a community.
141 pub struct EditCommunity {
142 pub community_id: CommunityId,
144 pub title: Option<String>,
145 /// A longer sidebar, or description of your community, in markdown.
146 pub description: Option<String>,
148 pub icon: Option<String>,
150 pub banner: Option<String>,
151 /// Whether its an NSFW community.
152 pub nsfw: Option<bool>,
153 /// Whether to restrict posting only to moderators.
154 pub posting_restricted_to_mods: Option<bool>,
155 pub discussion_languages: Option<Vec<LanguageId>>,
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 /// Hide a community from the main view.
164 // TODO this should really be a part of edit community. And why does it contain a reason, that should be in the mod tables.
165 pub struct HideCommunity {
166 pub community_id: CommunityId,
168 pub reason: Option<String>,
169 pub auth: Sensitive<String>,
172 #[skip_serializing_none]
173 #[derive(Debug, Serialize, Deserialize, Clone, Default)]
174 #[cfg_attr(feature = "full", derive(TS))]
175 #[cfg_attr(feature = "full", ts(export))]
176 /// Delete your own community.
177 pub struct DeleteCommunity {
178 pub community_id: CommunityId,
180 pub auth: Sensitive<String>,
183 #[skip_serializing_none]
184 #[derive(Debug, Serialize, Deserialize, Clone, Default)]
185 #[cfg_attr(feature = "full", derive(TS))]
186 #[cfg_attr(feature = "full", ts(export))]
187 /// Remove a community (only doable by moderators).
188 pub struct RemoveCommunity {
189 pub community_id: CommunityId,
191 pub reason: Option<String>,
192 pub expires: Option<i64>,
193 pub auth: Sensitive<String>,
196 #[derive(Debug, Serialize, Deserialize, Clone, Default)]
197 #[cfg_attr(feature = "full", derive(TS))]
198 #[cfg_attr(feature = "full", ts(export))]
199 /// Follow / subscribe to a community.
200 pub struct FollowCommunity {
201 pub community_id: CommunityId,
203 pub auth: Sensitive<String>,
206 #[derive(Debug, Serialize, Deserialize, Clone, Default)]
207 #[cfg_attr(feature = "full", derive(TS))]
208 #[cfg_attr(feature = "full", ts(export))]
209 /// Block a community.
210 pub struct BlockCommunity {
211 pub community_id: CommunityId,
213 pub auth: Sensitive<String>,
216 #[skip_serializing_none]
217 #[derive(Debug, Serialize, Deserialize, Clone)]
218 #[cfg_attr(feature = "full", derive(TS))]
219 #[cfg_attr(feature = "full", ts(export))]
220 /// The block community response.
221 pub struct BlockCommunityResponse {
222 pub community_view: CommunityView,
226 #[derive(Debug, Serialize, Deserialize, Clone, Default)]
227 #[cfg_attr(feature = "full", derive(TS))]
228 #[cfg_attr(feature = "full", ts(export))]
229 /// Transfer a community to a new owner.
230 pub struct TransferCommunity {
231 pub community_id: CommunityId,
232 pub person_id: PersonId,
233 pub auth: Sensitive<String>,