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