]> Untitled Git - lemmy.git/blob - crates/api_structs/src/comment.rs
Fixing image locations.
[lemmy.git] / crates / api_structs / src / comment.rs
1 use lemmy_db_schema::{CommentId, 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 parent_id: Option<CommentId>,
9   pub post_id: PostId,
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_: String,
68   pub sort: 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: bool,
74   pub auth: Option<String>,
75 }
76
77 #[derive(Serialize)]
78 pub struct GetCommentsResponse {
79   pub comments: Vec<CommentView>,
80 }
81
82 #[derive(Serialize, Deserialize)]
83 pub struct CreateCommentReport {
84   pub comment_id: CommentId,
85   pub reason: String,
86   pub auth: String,
87 }
88
89 #[derive(Serialize, Deserialize, Clone)]
90 pub struct CreateCommentReportResponse {
91   pub success: bool,
92 }
93
94 #[derive(Serialize, Deserialize, Debug)]
95 pub struct ResolveCommentReport {
96   pub report_id: i32,
97   pub resolved: bool,
98   pub auth: String,
99 }
100
101 #[derive(Serialize, Deserialize, Clone, Debug)]
102 pub struct ResolveCommentReportResponse {
103   // TODO this should probably return the view
104   pub report_id: i32,
105   pub resolved: bool,
106 }
107
108 #[derive(Serialize, Deserialize, Debug)]
109 pub struct ListCommentReports {
110   pub page: Option<i64>,
111   pub limit: Option<i64>,
112   /// if no community is given, it returns reports for all communities moderated by the auth user
113   pub community: Option<CommunityId>,
114   pub auth: String,
115 }
116
117 #[derive(Serialize, Clone, Debug)]
118 pub struct ListCommentReportsResponse {
119   pub comments: Vec<CommentReportView>,
120 }