1 use crate::sensitive::Sensitive;
3 newtypes::{CommentId, CommentReportId, CommunityId, LanguageId, LocalUserId, PostId},
7 use lemmy_db_views::structs::{CommentReportView, CommentView};
8 use serde::{Deserialize, Serialize};
9 use serde_with::skip_serializing_none;
10 #[cfg(feature = "full")]
13 #[skip_serializing_none]
14 #[derive(Debug, Serialize, Deserialize, Clone, Default)]
15 #[cfg_attr(feature = "full", derive(TS))]
16 #[cfg_attr(feature = "full", ts(export))]
18 pub struct CreateComment {
21 pub parent_id: Option<CommentId>,
22 pub language_id: Option<LanguageId>,
23 /// An optional front-end ID, to help UIs determine where the comment should go.
24 pub form_id: Option<String>,
25 pub auth: Sensitive<String>,
28 #[skip_serializing_none]
29 #[derive(Debug, Serialize, Deserialize, Clone, Default)]
30 #[cfg_attr(feature = "full", derive(TS))]
31 #[cfg_attr(feature = "full", ts(export))]
32 /// Fetch an individual comment.
33 pub struct GetComment {
35 pub auth: Option<Sensitive<String>>,
38 #[skip_serializing_none]
39 #[derive(Debug, Serialize, Deserialize, Clone, Default)]
40 #[cfg_attr(feature = "full", derive(TS))]
41 #[cfg_attr(feature = "full", ts(export))]
43 pub struct EditComment {
44 pub comment_id: CommentId,
45 pub content: Option<String>,
46 pub language_id: Option<LanguageId>,
47 pub form_id: Option<String>,
48 pub auth: Sensitive<String>,
51 #[skip_serializing_none]
52 #[derive(Debug, Serialize, Deserialize, Clone, Default)]
53 #[cfg_attr(feature = "full", derive(TS))]
54 #[cfg_attr(feature = "full", ts(export))]
55 /// Distinguish a comment (IE speak as moderator).
56 pub struct DistinguishComment {
57 pub comment_id: CommentId,
58 pub distinguished: bool,
59 pub auth: Sensitive<String>,
62 #[skip_serializing_none]
63 #[derive(Debug, Serialize, Deserialize, Clone, Default)]
64 #[cfg_attr(feature = "full", derive(TS))]
65 #[cfg_attr(feature = "full", ts(export))]
66 /// Delete your own comment.
67 pub struct DeleteComment {
68 pub comment_id: CommentId,
70 pub auth: Sensitive<String>,
73 #[skip_serializing_none]
74 #[derive(Debug, Serialize, Deserialize, Clone, Default)]
75 #[cfg_attr(feature = "full", derive(TS))]
76 #[cfg_attr(feature = "full", ts(export))]
77 /// Remove a comment (only doable by mods).
78 pub struct RemoveComment {
79 pub comment_id: CommentId,
81 pub reason: Option<String>,
82 pub auth: Sensitive<String>,
85 #[derive(Debug, Serialize, Deserialize, Clone, Default)]
86 #[cfg_attr(feature = "full", derive(TS))]
87 #[cfg_attr(feature = "full", ts(export))]
88 /// Save / bookmark a comment.
89 pub struct SaveComment {
90 pub comment_id: CommentId,
92 pub auth: Sensitive<String>,
95 #[skip_serializing_none]
96 #[derive(Debug, Serialize, Deserialize, Clone)]
97 #[cfg_attr(feature = "full", derive(TS))]
98 #[cfg_attr(feature = "full", ts(export))]
99 /// A comment response.
100 pub struct CommentResponse {
101 pub comment_view: CommentView,
102 pub recipient_ids: Vec<LocalUserId>,
103 /// An optional front end ID, to tell which is coming back
104 pub form_id: Option<String>,
107 #[derive(Debug, Serialize, Deserialize, Clone, Default)]
108 #[cfg_attr(feature = "full", derive(TS))]
109 #[cfg_attr(feature = "full", ts(export))]
111 pub struct CreateCommentLike {
112 pub comment_id: CommentId,
113 /// Must be -1, 0, or 1 .
115 pub auth: Sensitive<String>,
118 #[skip_serializing_none]
119 #[derive(Debug, Serialize, Deserialize, Clone, Default)]
120 #[cfg_attr(feature = "full", derive(TS))]
121 #[cfg_attr(feature = "full", ts(export))]
122 /// Get a list of comments.
123 pub struct GetComments {
124 pub type_: Option<ListingType>,
125 pub sort: Option<CommentSortType>,
126 pub max_depth: Option<i32>,
127 pub page: Option<i64>,
128 pub limit: Option<i64>,
129 pub community_id: Option<CommunityId>,
130 pub community_name: Option<String>,
131 pub post_id: Option<PostId>,
132 pub parent_id: Option<CommentId>,
133 pub saved_only: Option<bool>,
134 pub auth: Option<Sensitive<String>>,
137 #[derive(Debug, Serialize, Deserialize, Clone)]
138 #[cfg_attr(feature = "full", derive(TS))]
139 #[cfg_attr(feature = "full", ts(export))]
140 /// The comment list response.
141 pub struct GetCommentsResponse {
142 pub comments: Vec<CommentView>,
145 #[derive(Debug, Serialize, Deserialize, Clone, Default)]
146 #[cfg_attr(feature = "full", derive(TS))]
147 #[cfg_attr(feature = "full", ts(export))]
148 /// Report a comment.
149 pub struct CreateCommentReport {
150 pub comment_id: CommentId,
152 pub auth: Sensitive<String>,
155 #[derive(Debug, Serialize, Deserialize, Clone)]
156 #[cfg_attr(feature = "full", derive(TS))]
157 #[cfg_attr(feature = "full", ts(export))]
158 /// The comment report response.
159 pub struct CommentReportResponse {
160 pub comment_report_view: CommentReportView,
163 #[derive(Debug, Serialize, Deserialize, Clone, Default)]
164 #[cfg_attr(feature = "full", derive(TS))]
165 #[cfg_attr(feature = "full", ts(export))]
166 /// Resolve a comment report (only doable by mods).
167 pub struct ResolveCommentReport {
168 pub report_id: CommentReportId,
170 pub auth: Sensitive<String>,
173 #[skip_serializing_none]
174 #[derive(Debug, Serialize, Deserialize, Clone, Default)]
175 #[cfg_attr(feature = "full", derive(TS))]
176 #[cfg_attr(feature = "full", ts(export))]
177 /// List comment reports.
178 pub struct ListCommentReports {
179 pub page: Option<i64>,
180 pub limit: Option<i64>,
181 /// Only shows the unresolved reports
182 pub unresolved_only: Option<bool>,
183 /// if no community is given, it returns reports for all communities moderated by the auth user
184 pub community_id: Option<CommunityId>,
185 pub auth: Sensitive<String>,
188 #[derive(Debug, Serialize, Deserialize, Clone)]
189 #[cfg_attr(feature = "full", derive(TS))]
190 #[cfg_attr(feature = "full", ts(export))]
191 /// The comment report list response.
192 pub struct ListCommentReportsResponse {
193 pub comment_reports: Vec<CommentReportView>,