]> Untitled Git - lemmy.git/blob - lemmy_structs/src/post.rs
Some API cleanup, adding site_id to site aggregates.
[lemmy.git] / lemmy_structs / src / post.rs
1 use lemmy_db::views::{
2   comment_view::CommentView,
3   community::community_moderator_view::CommunityModeratorView,
4   post_report_view::PostReportView,
5   post_view::PostView,
6 };
7 use serde::{Deserialize, Serialize};
8
9 #[derive(Deserialize, Debug)]
10 pub struct CreatePost {
11   pub name: String,
12   pub url: Option<String>,
13   pub body: Option<String>,
14   pub nsfw: bool,
15   pub community_id: i32,
16   pub auth: String,
17 }
18
19 #[derive(Serialize, Clone)]
20 pub struct PostResponse {
21   pub post_view: PostView,
22 }
23
24 #[derive(Deserialize)]
25 pub struct GetPost {
26   pub id: i32,
27   pub auth: Option<String>,
28 }
29
30 #[derive(Serialize)]
31 pub struct GetPostResponse {
32   pub post_view: PostView,
33   pub comments: Vec<CommentView>,
34   pub moderators: Vec<CommunityModeratorView>,
35   pub online: usize,
36 }
37
38 #[derive(Deserialize, Debug)]
39 pub struct GetPosts {
40   pub type_: String,
41   pub sort: String,
42   pub page: Option<i64>,
43   pub limit: Option<i64>,
44   pub community_id: Option<i32>,
45   pub community_name: Option<String>,
46   pub auth: Option<String>,
47 }
48
49 #[derive(Serialize, Debug)]
50 pub struct GetPostsResponse {
51   pub posts: Vec<PostView>,
52 }
53
54 #[derive(Deserialize)]
55 pub struct CreatePostLike {
56   pub post_id: i32,
57   pub score: i16,
58   pub auth: String,
59 }
60
61 #[derive(Deserialize)]
62 pub struct EditPost {
63   pub edit_id: i32,
64   pub name: String,
65   pub url: Option<String>,
66   pub body: Option<String>,
67   pub nsfw: bool,
68   pub auth: String,
69 }
70
71 #[derive(Deserialize)]
72 pub struct DeletePost {
73   pub edit_id: i32,
74   pub deleted: bool,
75   pub auth: String,
76 }
77
78 #[derive(Deserialize)]
79 pub struct RemovePost {
80   pub edit_id: i32,
81   pub removed: bool,
82   pub reason: Option<String>,
83   pub auth: String,
84 }
85
86 #[derive(Deserialize)]
87 pub struct LockPost {
88   pub edit_id: i32,
89   pub locked: bool,
90   pub auth: String,
91 }
92
93 #[derive(Deserialize)]
94 pub struct StickyPost {
95   pub edit_id: i32,
96   pub stickied: bool,
97   pub auth: String,
98 }
99
100 #[derive(Deserialize)]
101 pub struct SavePost {
102   pub post_id: i32,
103   pub save: bool,
104   pub auth: String,
105 }
106
107 #[derive(Deserialize, Debug)]
108 pub struct PostJoin {
109   pub post_id: i32,
110 }
111
112 #[derive(Serialize, Clone)]
113 pub struct PostJoinResponse {
114   pub joined: bool,
115 }
116
117 #[derive(Serialize, Deserialize)]
118 pub struct CreatePostReport {
119   pub post_id: i32,
120   pub reason: String,
121   pub auth: String,
122 }
123
124 #[derive(Serialize, Deserialize, Clone)]
125 pub struct CreatePostReportResponse {
126   pub success: bool,
127 }
128
129 #[derive(Serialize, Deserialize, Debug)]
130 pub struct ResolvePostReport {
131   pub report_id: i32,
132   pub resolved: bool,
133   pub auth: String,
134 }
135
136 #[derive(Serialize, Deserialize, Clone, Debug)]
137 pub struct ResolvePostReportResponse {
138   pub report_id: i32,
139   pub resolved: bool,
140 }
141
142 #[derive(Serialize, Deserialize, Debug)]
143 pub struct ListPostReports {
144   pub page: Option<i64>,
145   pub limit: Option<i64>,
146   pub community: Option<i32>,
147   pub auth: String,
148 }
149
150 #[derive(Serialize, Clone, Debug)]
151 pub struct ListPostReportsResponse {
152   pub posts: Vec<PostReportView>,
153 }