]> Untitled Git - lemmy.git/blob - lemmy_structs/src/post.rs
fe6a059e2ecf3fac070686041738f80b5c2782b1
[lemmy.git] / lemmy_structs / src / post.rs
1 use lemmy_db::views::{
2   comment_view::CommentView,
3   community::{community_moderator_view::CommunityModeratorView, community_view::CommunityView},
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 community: CommunityView,
35   pub moderators: Vec<CommunityModeratorView>,
36   pub online: usize,
37 }
38
39 #[derive(Deserialize, Debug)]
40 pub struct GetPosts {
41   pub type_: String,
42   pub sort: String,
43   pub page: Option<i64>,
44   pub limit: Option<i64>,
45   pub community_id: Option<i32>,
46   pub community_name: Option<String>,
47   pub auth: Option<String>,
48 }
49
50 #[derive(Serialize, Debug)]
51 pub struct GetPostsResponse {
52   pub posts: Vec<PostView>,
53 }
54
55 #[derive(Deserialize)]
56 pub struct CreatePostLike {
57   pub post_id: i32,
58   pub score: i16,
59   pub auth: String,
60 }
61
62 #[derive(Deserialize)]
63 pub struct EditPost {
64   pub edit_id: i32,
65   pub name: String,
66   pub url: Option<String>,
67   pub body: Option<String>,
68   pub nsfw: bool,
69   pub auth: String,
70 }
71
72 #[derive(Deserialize)]
73 pub struct DeletePost {
74   pub edit_id: i32,
75   pub deleted: bool,
76   pub auth: String,
77 }
78
79 #[derive(Deserialize)]
80 pub struct RemovePost {
81   pub edit_id: i32,
82   pub removed: bool,
83   pub reason: Option<String>,
84   pub auth: String,
85 }
86
87 #[derive(Deserialize)]
88 pub struct LockPost {
89   pub edit_id: i32,
90   pub locked: bool,
91   pub auth: String,
92 }
93
94 #[derive(Deserialize)]
95 pub struct StickyPost {
96   pub edit_id: i32,
97   pub stickied: bool,
98   pub auth: String,
99 }
100
101 #[derive(Deserialize)]
102 pub struct SavePost {
103   pub post_id: i32,
104   pub save: bool,
105   pub auth: String,
106 }
107
108 #[derive(Deserialize, Debug)]
109 pub struct PostJoin {
110   pub post_id: i32,
111 }
112
113 #[derive(Serialize, Clone)]
114 pub struct PostJoinResponse {
115   pub joined: bool,
116 }
117
118 #[derive(Serialize, Deserialize)]
119 pub struct CreatePostReport {
120   pub post_id: i32,
121   pub reason: String,
122   pub auth: String,
123 }
124
125 #[derive(Serialize, Deserialize, Clone)]
126 pub struct CreatePostReportResponse {
127   pub success: bool,
128 }
129
130 #[derive(Serialize, Deserialize, Debug)]
131 pub struct ResolvePostReport {
132   pub report_id: i32,
133   pub resolved: bool,
134   pub auth: String,
135 }
136
137 #[derive(Serialize, Deserialize, Clone, Debug)]
138 pub struct ResolvePostReportResponse {
139   pub report_id: i32,
140   pub resolved: bool,
141 }
142
143 #[derive(Serialize, Deserialize, Debug)]
144 pub struct ListPostReports {
145   pub page: Option<i64>,
146   pub limit: Option<i64>,
147   pub community: Option<i32>,
148   pub auth: String,
149 }
150
151 #[derive(Serialize, Clone, Debug)]
152 pub struct ListPostReportsResponse {
153   pub posts: Vec<PostReportView>,
154 }