]> Untitled Git - lemmy.git/blob - lemmy_structs/src/community.rs
Merge pull request #1328 from LemmyNet/move_views_to_diesel
[lemmy.git] / lemmy_structs / src / community.rs
1 use lemmy_db_views_actor::{
2   community_follower_view::CommunityFollowerView,
3   community_moderator_view::CommunityModeratorView,
4   community_view::CommunityView,
5   user_view::UserViewSafe,
6 };
7 use serde::{Deserialize, Serialize};
8
9 #[derive(Deserialize)]
10 pub struct GetCommunity {
11   pub id: Option<i32>,
12   pub name: Option<String>,
13   pub auth: Option<String>,
14 }
15
16 #[derive(Serialize)]
17 pub struct GetCommunityResponse {
18   pub community_view: CommunityView,
19   pub moderators: Vec<CommunityModeratorView>,
20   pub online: usize,
21 }
22
23 #[derive(Deserialize)]
24 pub struct CreateCommunity {
25   pub name: String,
26   pub title: String,
27   pub description: Option<String>,
28   pub icon: Option<String>,
29   pub banner: Option<String>,
30   pub category_id: i32,
31   pub nsfw: bool,
32   pub auth: String,
33 }
34
35 #[derive(Serialize, Clone)]
36 pub struct CommunityResponse {
37   pub community_view: CommunityView,
38 }
39
40 #[derive(Deserialize, Debug)]
41 pub struct ListCommunities {
42   pub sort: String,
43   pub page: Option<i64>,
44   pub limit: Option<i64>,
45   pub auth: Option<String>,
46 }
47
48 #[derive(Serialize, Debug)]
49 pub struct ListCommunitiesResponse {
50   pub communities: Vec<CommunityView>,
51 }
52
53 #[derive(Deserialize, Clone)]
54 pub struct BanFromCommunity {
55   pub community_id: i32,
56   pub user_id: i32,
57   pub ban: bool,
58   pub remove_data: bool,
59   pub reason: Option<String>,
60   pub expires: Option<i64>,
61   pub auth: String,
62 }
63
64 #[derive(Serialize, Clone)]
65 pub struct BanFromCommunityResponse {
66   pub user_view: UserViewSafe,
67   pub banned: bool,
68 }
69
70 #[derive(Deserialize)]
71 pub struct AddModToCommunity {
72   pub community_id: i32,
73   pub user_id: i32,
74   pub added: bool,
75   pub auth: String,
76 }
77
78 #[derive(Serialize, Clone)]
79 pub struct AddModToCommunityResponse {
80   pub moderators: Vec<CommunityModeratorView>,
81 }
82
83 #[derive(Deserialize)]
84 pub struct EditCommunity {
85   pub community_id: i32,
86   pub title: String,
87   pub description: Option<String>,
88   pub icon: Option<String>,
89   pub banner: Option<String>,
90   pub category_id: i32,
91   pub nsfw: bool,
92   pub auth: String,
93 }
94
95 #[derive(Deserialize)]
96 pub struct DeleteCommunity {
97   pub community_id: i32,
98   pub deleted: bool,
99   pub auth: String,
100 }
101
102 #[derive(Deserialize)]
103 pub struct RemoveCommunity {
104   pub community_id: i32,
105   pub removed: bool,
106   pub reason: Option<String>,
107   pub expires: Option<i64>,
108   pub auth: String,
109 }
110
111 #[derive(Deserialize)]
112 pub struct FollowCommunity {
113   pub community_id: i32,
114   pub follow: bool,
115   pub auth: String,
116 }
117
118 #[derive(Deserialize)]
119 pub struct GetFollowedCommunities {
120   pub auth: String,
121 }
122
123 #[derive(Serialize)]
124 pub struct GetFollowedCommunitiesResponse {
125   pub communities: Vec<CommunityFollowerView>,
126 }
127
128 #[derive(Deserialize)]
129 pub struct TransferCommunity {
130   pub community_id: i32,
131   pub user_id: i32,
132   pub auth: String,
133 }