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