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