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