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};
11 #[derive(Debug, Serialize, Deserialize, Clone, Default)]
12 pub struct GetCommunity {
13 pub id: Option<CommunityId>,
14 /// Example: star_trek , or star_trek@xyz.tld
15 pub name: Option<String>,
16 pub auth: Option<Sensitive<String>>,
19 #[derive(Debug, Serialize, Deserialize, Clone)]
20 pub struct GetCommunityResponse {
21 pub community_view: CommunityView,
22 pub site: Option<Site>,
23 pub moderators: Vec<CommunityModeratorView>,
25 pub discussion_languages: Vec<LanguageId>,
26 /// Default language used for new posts if none is specified, generated based on community and
28 pub default_post_language: Option<LanguageId>,
31 #[derive(Debug, Serialize, Deserialize, Clone, Default)]
32 pub struct CreateCommunity {
35 pub description: Option<String>,
36 pub icon: Option<String>,
37 pub banner: Option<String>,
38 pub nsfw: Option<bool>,
39 pub posting_restricted_to_mods: Option<bool>,
40 pub discussion_languages: Option<Vec<LanguageId>>,
41 pub auth: Sensitive<String>,
44 #[derive(Debug, Serialize, Deserialize, Clone)]
45 pub struct CommunityResponse {
46 pub community_view: CommunityView,
47 pub discussion_languages: Vec<LanguageId>,
50 #[derive(Debug, Serialize, Deserialize, Clone, Default)]
51 pub struct ListCommunities {
52 pub type_: Option<ListingType>,
53 pub sort: Option<SortType>,
54 pub page: Option<i64>,
55 pub limit: Option<i64>,
56 pub auth: Option<Sensitive<String>>,
59 #[derive(Debug, Serialize, Deserialize, Clone)]
60 pub struct ListCommunitiesResponse {
61 pub communities: Vec<CommunityView>,
64 #[derive(Debug, Serialize, Deserialize, Clone, Default)]
65 pub struct BanFromCommunity {
66 pub community_id: CommunityId,
67 pub person_id: PersonId,
69 pub remove_data: Option<bool>,
70 pub reason: Option<String>,
71 pub expires: Option<i64>,
72 pub auth: Sensitive<String>,
75 #[derive(Debug, Serialize, Deserialize, Clone)]
76 pub struct BanFromCommunityResponse {
77 pub person_view: PersonView,
81 #[derive(Debug, Serialize, Deserialize, Clone, Default)]
82 pub struct AddModToCommunity {
83 pub community_id: CommunityId,
84 pub person_id: PersonId,
86 pub auth: Sensitive<String>,
89 #[derive(Debug, Serialize, Deserialize, Clone)]
90 pub struct AddModToCommunityResponse {
91 pub moderators: Vec<CommunityModeratorView>,
94 #[derive(Debug, Serialize, Deserialize, Clone, Default)]
95 pub struct EditCommunity {
96 pub community_id: CommunityId,
97 pub title: Option<String>,
98 pub description: Option<String>,
99 pub icon: Option<String>,
100 pub banner: Option<String>,
101 pub nsfw: Option<bool>,
102 pub posting_restricted_to_mods: Option<bool>,
103 pub discussion_languages: Option<Vec<LanguageId>>,
104 pub auth: Sensitive<String>,
107 #[derive(Debug, Serialize, Deserialize, Clone, Default)]
108 pub struct HideCommunity {
109 pub community_id: CommunityId,
111 pub reason: Option<String>,
112 pub auth: Sensitive<String>,
115 #[derive(Debug, Serialize, Deserialize, Clone, Default)]
116 pub struct DeleteCommunity {
117 pub community_id: CommunityId,
119 pub auth: Sensitive<String>,
122 #[derive(Debug, Serialize, Deserialize, Clone, Default)]
123 pub struct RemoveCommunity {
124 pub community_id: CommunityId,
126 pub reason: Option<String>,
127 pub expires: Option<i64>,
128 pub auth: Sensitive<String>,
131 #[derive(Debug, Serialize, Deserialize, Clone, Default)]
132 pub struct FollowCommunity {
133 pub community_id: CommunityId,
135 pub auth: Sensitive<String>,
138 #[derive(Debug, Serialize, Deserialize, Clone, Default)]
139 pub struct BlockCommunity {
140 pub community_id: CommunityId,
142 pub auth: Sensitive<String>,
145 #[derive(Debug, Serialize, Deserialize, Clone)]
146 pub struct BlockCommunityResponse {
147 pub community_view: CommunityView,
151 #[derive(Debug, Serialize, Deserialize, Clone, Default)]
152 pub struct TransferCommunity {
153 pub community_id: CommunityId,
154 pub person_id: PersonId,
155 pub auth: Sensitive<String>,