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 pub auth: Sensitive<String>,
26 #[skip_serializing_none]
27 #[derive(Debug, Serialize, Deserialize, Clone, Default)]
28 #[cfg_attr(feature = "full", derive(TS))]
29 #[cfg_attr(feature = "full", ts(export))]
30 /// Fetch an individual comment.
31 pub struct GetComment {
33 pub auth: Option<Sensitive<String>>,
36 #[skip_serializing_none]
37 #[derive(Debug, Serialize, Deserialize, Clone, Default)]
38 #[cfg_attr(feature = "full", derive(TS))]
39 #[cfg_attr(feature = "full", ts(export))]
41 pub struct EditComment {
42 pub comment_id: CommentId,
43 pub content: Option<String>,
44 pub language_id: Option<LanguageId>,
45 pub auth: Sensitive<String>,
48 #[skip_serializing_none]
49 #[derive(Debug, Serialize, Deserialize, Clone, Default)]
50 #[cfg_attr(feature = "full", derive(TS))]
51 #[cfg_attr(feature = "full", ts(export))]
52 /// Distinguish a comment (IE speak as moderator).
53 pub struct DistinguishComment {
54 pub comment_id: CommentId,
55 pub distinguished: bool,
56 pub auth: Sensitive<String>,
59 #[skip_serializing_none]
60 #[derive(Debug, Serialize, Deserialize, Clone, Default)]
61 #[cfg_attr(feature = "full", derive(TS))]
62 #[cfg_attr(feature = "full", ts(export))]
63 /// Delete your own comment.
64 pub struct DeleteComment {
65 pub comment_id: CommentId,
67 pub auth: Sensitive<String>,
70 #[skip_serializing_none]
71 #[derive(Debug, Serialize, Deserialize, Clone, Default)]
72 #[cfg_attr(feature = "full", derive(TS))]
73 #[cfg_attr(feature = "full", ts(export))]
74 /// Remove a comment (only doable by mods).
75 pub struct RemoveComment {
76 pub comment_id: CommentId,
78 pub reason: Option<String>,
79 pub auth: Sensitive<String>,
82 #[derive(Debug, Serialize, Deserialize, Clone, Default)]
83 #[cfg_attr(feature = "full", derive(TS))]
84 #[cfg_attr(feature = "full", ts(export))]
85 /// Save / bookmark a comment.
86 pub struct SaveComment {
87 pub comment_id: CommentId,
89 pub auth: Sensitive<String>,
92 #[skip_serializing_none]
93 #[derive(Debug, Serialize, Deserialize, Clone)]
94 #[cfg_attr(feature = "full", derive(TS))]
95 #[cfg_attr(feature = "full", ts(export))]
96 /// A comment response.
97 pub struct CommentResponse {
98 pub comment_view: CommentView,
99 pub recipient_ids: Vec<LocalUserId>,
102 #[derive(Debug, Serialize, Deserialize, Clone, Default)]
103 #[cfg_attr(feature = "full", derive(TS))]
104 #[cfg_attr(feature = "full", ts(export))]
106 pub struct CreateCommentLike {
107 pub comment_id: CommentId,
108 /// Must be -1, 0, or 1 .
110 pub auth: Sensitive<String>,
113 #[skip_serializing_none]
114 #[derive(Debug, Serialize, Deserialize, Clone, Default)]
115 #[cfg_attr(feature = "full", derive(TS))]
116 #[cfg_attr(feature = "full", ts(export))]
117 /// Get a list of comments.
118 pub struct GetComments {
119 pub type_: Option<ListingType>,
120 pub sort: Option<CommentSortType>,
121 pub max_depth: Option<i32>,
122 pub page: Option<i64>,
123 pub limit: Option<i64>,
124 pub community_id: Option<CommunityId>,
125 pub community_name: Option<String>,
126 pub post_id: Option<PostId>,
127 pub parent_id: Option<CommentId>,
128 pub saved_only: Option<bool>,
129 pub liked_only: Option<bool>,
130 pub disliked_only: Option<bool>,
131 pub auth: Option<Sensitive<String>>,
134 #[derive(Debug, Serialize, Deserialize, Clone)]
135 #[cfg_attr(feature = "full", derive(TS))]
136 #[cfg_attr(feature = "full", ts(export))]
137 /// The comment list response.
138 pub struct GetCommentsResponse {
139 pub comments: Vec<CommentView>,
142 #[derive(Debug, Serialize, Deserialize, Clone, Default)]
143 #[cfg_attr(feature = "full", derive(TS))]
144 #[cfg_attr(feature = "full", ts(export))]
145 /// Report a comment.
146 pub struct CreateCommentReport {
147 pub comment_id: CommentId,
149 pub auth: Sensitive<String>,
152 #[derive(Debug, Serialize, Deserialize, Clone)]
153 #[cfg_attr(feature = "full", derive(TS))]
154 #[cfg_attr(feature = "full", ts(export))]
155 /// The comment report response.
156 pub struct CommentReportResponse {
157 pub comment_report_view: CommentReportView,
160 #[derive(Debug, Serialize, Deserialize, Clone, Default)]
161 #[cfg_attr(feature = "full", derive(TS))]
162 #[cfg_attr(feature = "full", ts(export))]
163 /// Resolve a comment report (only doable by mods).
164 pub struct ResolveCommentReport {
165 pub report_id: CommentReportId,
167 pub auth: Sensitive<String>,
170 #[skip_serializing_none]
171 #[derive(Debug, Serialize, Deserialize, Clone, Default)]
172 #[cfg_attr(feature = "full", derive(TS))]
173 #[cfg_attr(feature = "full", ts(export))]
174 /// List comment reports.
175 pub struct ListCommentReports {
176 pub page: Option<i64>,
177 pub limit: Option<i64>,
178 /// Only shows the unresolved reports
179 pub unresolved_only: Option<bool>,
180 /// if no community is given, it returns reports for all communities moderated by the auth user
181 pub community_id: Option<CommunityId>,
182 pub auth: Sensitive<String>,
185 #[derive(Debug, Serialize, Deserialize, Clone)]
186 #[cfg_attr(feature = "full", derive(TS))]
187 #[cfg_attr(feature = "full", ts(export))]
188 /// The comment report list response.
189 pub struct ListCommentReportsResponse {
190 pub comment_reports: Vec<CommentReportView>,