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