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