]> Untitled Git - lemmy.git/blob - crates/api_common/src/post.rs
Run cargo check for each crate with different features (ref #2284) (#2292)
[lemmy.git] / crates / api_common / src / post.rs
1 use crate::sensitive::Sensitive;
2 use lemmy_db_schema::{
3   newtypes::{CommunityId, PostId, PostReportId},
4   ListingType,
5   SortType,
6 };
7 use lemmy_db_views::structs::{CommentView, PostReportView, PostView};
8 use lemmy_db_views_actor::structs::{CommunityModeratorView, CommunityView};
9 use serde::{Deserialize, Serialize};
10 use url::Url;
11
12 #[derive(Debug, Serialize, Deserialize, Clone, Default)]
13 pub struct CreatePost {
14   pub name: String,
15   pub community_id: CommunityId,
16   pub url: Option<Url>,
17   pub body: Option<String>,
18   pub honeypot: Option<String>,
19   pub nsfw: Option<bool>,
20   pub auth: Sensitive<String>,
21 }
22
23 #[derive(Debug, Serialize, Deserialize, Clone)]
24 pub struct PostResponse {
25   pub post_view: PostView,
26 }
27
28 #[derive(Debug, Serialize, Deserialize, Clone, Default)]
29 pub struct GetPost {
30   pub id: PostId,
31   pub auth: Option<Sensitive<String>>,
32 }
33
34 #[derive(Debug, Serialize, Deserialize, Clone)]
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(Serialize, Deserialize, Debug, Clone, Default)]
44 pub struct GetPosts {
45   pub type_: Option<ListingType>,
46   pub sort: Option<SortType>,
47   pub page: Option<i64>,
48   pub limit: Option<i64>,
49   pub community_id: Option<CommunityId>,
50   pub community_name: Option<String>,
51   pub saved_only: Option<bool>,
52   pub auth: Option<Sensitive<String>>,
53 }
54
55 #[derive(Serialize, Deserialize, Debug, Clone)]
56 pub struct GetPostsResponse {
57   pub posts: Vec<PostView>,
58 }
59
60 #[derive(Debug, Serialize, Deserialize, Clone, Default)]
61 pub struct CreatePostLike {
62   pub post_id: PostId,
63   pub score: i16,
64   pub auth: Sensitive<String>,
65 }
66
67 #[derive(Debug, Serialize, Deserialize, Clone, Default)]
68 pub struct EditPost {
69   pub post_id: PostId,
70   pub name: Option<String>,
71   pub url: Option<Url>,
72   pub body: Option<String>,
73   pub nsfw: Option<bool>,
74   pub auth: Sensitive<String>,
75 }
76
77 #[derive(Debug, Serialize, Deserialize, Clone, Default)]
78 pub struct DeletePost {
79   pub post_id: PostId,
80   pub deleted: bool,
81   pub auth: Sensitive<String>,
82 }
83
84 #[derive(Debug, Serialize, Deserialize, Clone, Default)]
85 pub struct RemovePost {
86   pub post_id: PostId,
87   pub removed: bool,
88   pub reason: Option<String>,
89   pub auth: Sensitive<String>,
90 }
91
92 #[derive(Debug, Serialize, Deserialize, Clone, Default)]
93 pub struct MarkPostAsRead {
94   pub post_id: PostId,
95   pub read: bool,
96   pub auth: Sensitive<String>,
97 }
98
99 #[derive(Debug, Serialize, Deserialize, Clone, Default)]
100 pub struct LockPost {
101   pub post_id: PostId,
102   pub locked: bool,
103   pub auth: Sensitive<String>,
104 }
105
106 #[derive(Debug, Serialize, Deserialize, Clone, Default)]
107 pub struct StickyPost {
108   pub post_id: PostId,
109   pub stickied: bool,
110   pub auth: Sensitive<String>,
111 }
112
113 #[derive(Debug, Serialize, Deserialize, Clone, Default)]
114 pub struct SavePost {
115   pub post_id: PostId,
116   pub save: bool,
117   pub auth: Sensitive<String>,
118 }
119
120 #[derive(Debug, Serialize, Deserialize, Clone, Default)]
121 pub struct CreatePostReport {
122   pub post_id: PostId,
123   pub reason: String,
124   pub auth: Sensitive<String>,
125 }
126
127 #[derive(Debug, Serialize, Deserialize, Clone)]
128 pub struct PostReportResponse {
129   pub post_report_view: PostReportView,
130 }
131
132 #[derive(Debug, Serialize, Deserialize, Clone, Default)]
133 pub struct ResolvePostReport {
134   pub report_id: PostReportId,
135   pub resolved: bool,
136   pub auth: Sensitive<String>,
137 }
138
139 #[derive(Debug, Serialize, Deserialize, Clone, Default)]
140 pub struct ListPostReports {
141   pub page: Option<i64>,
142   pub limit: Option<i64>,
143   /// Only shows the unresolved reports
144   pub unresolved_only: Option<bool>,
145   /// if no community is given, it returns reports for all communities moderated by the auth user
146   pub community_id: Option<CommunityId>,
147   pub auth: Sensitive<String>,
148 }
149
150 #[derive(Debug, Serialize, Deserialize, Clone)]
151 pub struct ListPostReportsResponse {
152   pub post_reports: Vec<PostReportView>,
153 }
154
155 #[derive(Debug, Serialize, Deserialize, Clone)]
156 pub struct GetSiteMetadata {
157   pub url: Url,
158 }
159
160 #[derive(Debug, Serialize, Deserialize, Clone)]
161 pub struct GetSiteMetadataResponse {
162   pub metadata: SiteMetadata,
163 }
164
165 #[derive(Debug, Deserialize, Serialize, PartialEq, Clone)]
166 pub struct SiteMetadata {
167   pub title: Option<String>,
168   pub description: Option<String>,
169   pub(crate) image: Option<Url>,
170   pub html: Option<String>,
171 }