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