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