1 use crate::sensitive::Sensitive;
3 newtypes::{CommunityId, LanguageId, PersonId},
8 use lemmy_db_views_actor::structs::{CommunityModeratorView, CommunityView, PersonViewSafe};
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 auth: Sensitive<String>,
43 #[derive(Debug, Serialize, Deserialize, Clone)]
44 pub struct CommunityResponse {
45 pub community_view: CommunityView,
48 #[derive(Debug, Serialize, Deserialize, Clone, Default)]
49 pub struct ListCommunities {
50 pub type_: Option<ListingType>,
51 pub sort: Option<SortType>,
52 pub page: Option<i64>,
53 pub limit: Option<i64>,
54 pub auth: Option<Sensitive<String>>,
57 #[derive(Debug, Serialize, Deserialize, Clone)]
58 pub struct ListCommunitiesResponse {
59 pub communities: Vec<CommunityView>,
62 #[derive(Debug, Serialize, Deserialize, Clone, Default)]
63 pub struct BanFromCommunity {
64 pub community_id: CommunityId,
65 pub person_id: PersonId,
67 pub remove_data: Option<bool>,
68 pub reason: Option<String>,
69 pub expires: Option<i64>,
70 pub auth: Sensitive<String>,
73 #[derive(Debug, Serialize, Deserialize, Clone)]
74 pub struct BanFromCommunityResponse {
75 pub person_view: PersonViewSafe,
79 #[derive(Debug, Serialize, Deserialize, Clone, Default)]
80 pub struct AddModToCommunity {
81 pub community_id: CommunityId,
82 pub person_id: PersonId,
84 pub auth: Sensitive<String>,
87 #[derive(Debug, Serialize, Deserialize, Clone)]
88 pub struct AddModToCommunityResponse {
89 pub moderators: Vec<CommunityModeratorView>,
92 #[derive(Debug, Serialize, Deserialize, Clone, Default)]
93 pub struct EditCommunity {
94 pub community_id: CommunityId,
95 pub title: Option<String>,
96 pub description: Option<String>,
97 pub icon: Option<String>,
98 pub banner: Option<String>,
99 pub nsfw: Option<bool>,
100 pub posting_restricted_to_mods: Option<bool>,
101 pub discussion_languages: Option<Vec<LanguageId>>,
102 pub auth: Sensitive<String>,
105 #[derive(Debug, Serialize, Deserialize, Clone, Default)]
106 pub struct HideCommunity {
107 pub community_id: CommunityId,
109 pub reason: Option<String>,
110 pub auth: Sensitive<String>,
113 #[derive(Debug, Serialize, Deserialize, Clone, Default)]
114 pub struct DeleteCommunity {
115 pub community_id: CommunityId,
117 pub auth: Sensitive<String>,
120 #[derive(Debug, Serialize, Deserialize, Clone, Default)]
121 pub struct RemoveCommunity {
122 pub community_id: CommunityId,
124 pub reason: Option<String>,
125 pub expires: Option<i64>,
126 pub auth: Sensitive<String>,
129 #[derive(Debug, Serialize, Deserialize, Clone, Default)]
130 pub struct FollowCommunity {
131 pub community_id: CommunityId,
133 pub auth: Sensitive<String>,
136 #[derive(Debug, Serialize, Deserialize, Clone, Default)]
137 pub struct BlockCommunity {
138 pub community_id: CommunityId,
140 pub auth: Sensitive<String>,
143 #[derive(Debug, Serialize, Deserialize, Clone)]
144 pub struct BlockCommunityResponse {
145 pub community_view: CommunityView,
149 #[derive(Debug, Serialize, Deserialize, Clone, Default)]
150 pub struct TransferCommunity {
151 pub community_id: CommunityId,
152 pub person_id: PersonId,
153 pub auth: Sensitive<String>,