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