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>,
37 /// Default language used for new posts if none is specified, generated based on community and
39 pub default_post_language: Option<LanguageId>,
42 #[skip_serializing_none]
43 #[cfg_attr(feature = "full", derive(TS))]
44 #[cfg_attr(feature = "full", ts(export))]
45 #[derive(Debug, Serialize, Deserialize, Clone, Default)]
46 /// Create a community.
47 pub struct CreateCommunity {
52 /// A longer sidebar, or description of your community, in markdown.
53 pub description: Option<String>,
55 pub icon: Option<String>,
57 pub banner: Option<String>,
58 /// Whether its an NSFW community.
59 pub nsfw: Option<bool>,
60 /// Whether to restrict posting only to moderators.
61 pub posting_restricted_to_mods: Option<bool>,
62 pub discussion_languages: Option<Vec<LanguageId>>,
63 pub auth: Sensitive<String>,
66 #[derive(Debug, Serialize, Deserialize, Clone)]
67 #[cfg_attr(feature = "full", derive(TS))]
68 #[cfg_attr(feature = "full", ts(export))]
69 /// A simple community response.
70 pub struct CommunityResponse {
71 pub community_view: CommunityView,
72 pub discussion_languages: Vec<LanguageId>,
75 #[skip_serializing_none]
76 #[derive(Debug, Serialize, Deserialize, Clone, Default)]
77 #[cfg_attr(feature = "full", derive(TS))]
78 #[cfg_attr(feature = "full", ts(export))]
79 /// Fetches a list of communities.
80 pub struct ListCommunities {
81 pub type_: Option<ListingType>,
82 pub sort: Option<SortType>,
83 pub page: Option<i64>,
84 pub limit: Option<i64>,
85 pub auth: Option<Sensitive<String>>,
88 #[derive(Debug, Serialize, Deserialize, Clone)]
89 #[cfg_attr(feature = "full", derive(TS))]
90 #[cfg_attr(feature = "full", ts(export))]
91 /// The response for listing communities.
92 pub struct ListCommunitiesResponse {
93 pub communities: Vec<CommunityView>,
96 #[skip_serializing_none]
97 #[derive(Debug, Serialize, Deserialize, Clone, Default)]
98 #[cfg_attr(feature = "full", derive(TS))]
99 #[cfg_attr(feature = "full", ts(export))]
100 /// Ban a user from a community.
101 pub struct BanFromCommunity {
102 pub community_id: CommunityId,
103 pub person_id: PersonId,
105 pub remove_data: Option<bool>,
106 pub reason: Option<String>,
107 pub expires: Option<i64>,
108 pub auth: Sensitive<String>,
111 #[derive(Debug, Serialize, Deserialize, Clone)]
112 #[cfg_attr(feature = "full", derive(TS))]
113 #[cfg_attr(feature = "full", ts(export))]
114 /// The response for banning a user from a community.
115 pub struct BanFromCommunityResponse {
116 pub person_view: PersonView,
120 #[derive(Debug, Serialize, Deserialize, Clone, Default)]
121 #[cfg_attr(feature = "full", derive(TS))]
122 #[cfg_attr(feature = "full", ts(export))]
123 /// Add a moderator to a community.
124 pub struct AddModToCommunity {
125 pub community_id: CommunityId,
126 pub person_id: PersonId,
128 pub auth: Sensitive<String>,
131 #[derive(Debug, Serialize, Deserialize, Clone)]
132 #[cfg_attr(feature = "full", derive(TS))]
133 #[cfg_attr(feature = "full", ts(export))]
134 /// The response of adding a moderator to a community.
135 pub struct AddModToCommunityResponse {
136 pub moderators: Vec<CommunityModeratorView>,
139 #[skip_serializing_none]
140 #[derive(Debug, Serialize, Deserialize, Clone, Default)]
141 #[cfg_attr(feature = "full", derive(TS))]
142 #[cfg_attr(feature = "full", ts(export))]
143 /// Edit a community.
144 pub struct EditCommunity {
145 pub community_id: CommunityId,
147 pub title: Option<String>,
148 /// A longer sidebar, or description of your community, in markdown.
149 pub description: Option<String>,
151 pub icon: Option<String>,
153 pub banner: Option<String>,
154 /// Whether its an NSFW community.
155 pub nsfw: Option<bool>,
156 /// Whether to restrict posting only to moderators.
157 pub posting_restricted_to_mods: Option<bool>,
158 pub discussion_languages: Option<Vec<LanguageId>>,
159 pub auth: Sensitive<String>,
162 #[skip_serializing_none]
163 #[derive(Debug, Serialize, Deserialize, Clone, Default)]
164 #[cfg_attr(feature = "full", derive(TS))]
165 #[cfg_attr(feature = "full", ts(export))]
166 /// Hide a community from the main view.
167 // TODO this should really be a part of edit community. And why does it contain a reason, that should be in the mod tables.
168 pub struct HideCommunity {
169 pub community_id: CommunityId,
171 pub reason: Option<String>,
172 pub auth: Sensitive<String>,
175 #[skip_serializing_none]
176 #[derive(Debug, Serialize, Deserialize, Clone, Default)]
177 #[cfg_attr(feature = "full", derive(TS))]
178 #[cfg_attr(feature = "full", ts(export))]
179 /// Delete your own community.
180 pub struct DeleteCommunity {
181 pub community_id: CommunityId,
183 pub auth: Sensitive<String>,
186 #[skip_serializing_none]
187 #[derive(Debug, Serialize, Deserialize, Clone, Default)]
188 #[cfg_attr(feature = "full", derive(TS))]
189 #[cfg_attr(feature = "full", ts(export))]
190 /// Remove a community (only doable by moderators).
191 pub struct RemoveCommunity {
192 pub community_id: CommunityId,
194 pub reason: Option<String>,
195 pub expires: Option<i64>,
196 pub auth: Sensitive<String>,
199 #[derive(Debug, Serialize, Deserialize, Clone, Default)]
200 #[cfg_attr(feature = "full", derive(TS))]
201 #[cfg_attr(feature = "full", ts(export))]
202 /// Follow / subscribe to a community.
203 pub struct FollowCommunity {
204 pub community_id: CommunityId,
206 pub auth: Sensitive<String>,
209 #[derive(Debug, Serialize, Deserialize, Clone, Default)]
210 #[cfg_attr(feature = "full", derive(TS))]
211 #[cfg_attr(feature = "full", ts(export))]
212 /// Block a community.
213 pub struct BlockCommunity {
214 pub community_id: CommunityId,
216 pub auth: Sensitive<String>,
219 #[skip_serializing_none]
220 #[derive(Debug, Serialize, Deserialize, Clone)]
221 #[cfg_attr(feature = "full", derive(TS))]
222 #[cfg_attr(feature = "full", ts(export))]
223 /// The block community response.
224 pub struct BlockCommunityResponse {
225 pub community_view: CommunityView,
229 #[derive(Debug, Serialize, Deserialize, Clone, Default)]
230 #[cfg_attr(feature = "full", derive(TS))]
231 #[cfg_attr(feature = "full", ts(export))]
232 /// Transfer a community to a new owner.
233 pub struct TransferCommunity {
234 pub community_id: CommunityId,
235 pub person_id: PersonId,
236 pub auth: Sensitive<String>,