]> Untitled Git - lemmy.git/blob - crates/api_common/src/comment.rs
afe76a9950dca74f14622da116636d4af7b7554a
[lemmy.git] / crates / api_common / src / comment.rs
1 use lemmy_db_schema::newtypes::{CommentId, CommentReportId, CommunityId, LocalUserId, PostId};
2 use lemmy_db_views::{comment_report_view::CommentReportView, comment_view::CommentView};
3 use serde::{Deserialize, Serialize};
4
5 #[derive(Serialize, Deserialize)]
6 pub struct CreateComment {
7   pub content: String,
8   pub post_id: PostId,
9   pub parent_id: Option<CommentId>,
10   pub form_id: Option<String>,
11   pub auth: String,
12 }
13
14 #[derive(Serialize, Deserialize)]
15 pub struct GetComment {
16   pub id: CommentId,
17   pub auth: Option<String>,
18 }
19
20 #[derive(Serialize, Deserialize)]
21 pub struct EditComment {
22   pub content: String,
23   pub comment_id: CommentId,
24   pub form_id: Option<String>,
25   pub auth: String,
26 }
27
28 #[derive(Serialize, Deserialize)]
29 pub struct DeleteComment {
30   pub comment_id: CommentId,
31   pub deleted: bool,
32   pub auth: String,
33 }
34
35 #[derive(Serialize, Deserialize)]
36 pub struct RemoveComment {
37   pub comment_id: CommentId,
38   pub removed: bool,
39   pub reason: Option<String>,
40   pub auth: String,
41 }
42
43 #[derive(Serialize, Deserialize)]
44 pub struct MarkCommentAsRead {
45   pub comment_id: CommentId,
46   pub read: bool,
47   pub auth: String,
48 }
49
50 #[derive(Serialize, Deserialize)]
51 pub struct SaveComment {
52   pub comment_id: CommentId,
53   pub save: bool,
54   pub auth: String,
55 }
56
57 #[derive(Serialize, Deserialize, Clone)]
58 pub struct CommentResponse {
59   pub comment_view: CommentView,
60   pub recipient_ids: Vec<LocalUserId>,
61   pub form_id: Option<String>, // An optional front end ID, to tell which is coming back
62 }
63
64 #[derive(Serialize, Deserialize)]
65 pub struct CreateCommentLike {
66   pub comment_id: CommentId,
67   pub score: i16,
68   pub auth: String,
69 }
70
71 #[derive(Serialize, Deserialize)]
72 pub struct GetComments {
73   pub type_: Option<String>,
74   pub sort: Option<String>,
75   pub page: Option<i64>,
76   pub limit: Option<i64>,
77   pub community_id: Option<CommunityId>,
78   pub community_name: Option<String>,
79   pub saved_only: Option<bool>,
80   pub auth: Option<String>,
81 }
82
83 #[derive(Serialize, Deserialize)]
84 pub struct GetCommentsResponse {
85   pub comments: Vec<CommentView>,
86 }
87
88 #[derive(Serialize, Deserialize)]
89 pub struct CreateCommentReport {
90   pub comment_id: CommentId,
91   pub reason: String,
92   pub auth: String,
93 }
94
95 #[derive(Serialize, Deserialize, Clone)]
96 pub struct CommentReportResponse {
97   pub comment_report_view: CommentReportView,
98 }
99
100 #[derive(Serialize, Deserialize)]
101 pub struct ResolveCommentReport {
102   pub report_id: CommentReportId,
103   pub resolved: bool,
104   pub auth: String,
105 }
106
107 #[derive(Serialize, Deserialize)]
108 pub struct ListCommentReports {
109   pub page: Option<i64>,
110   pub limit: Option<i64>,
111   /// Only shows the unresolved reports
112   pub unresolved_only: Option<bool>,
113   /// if no community is given, it returns reports for all communities moderated by the auth user
114   pub community_id: Option<CommunityId>,
115   pub auth: String,
116 }
117
118 #[derive(Serialize, Deserialize)]
119 pub struct ListCommentReportsResponse {
120   pub comment_reports: Vec<CommentReportView>,
121 }