2022-05-06 20:55:07 +00:00
|
|
|
use lemmy_db_schema::{
|
2022-08-23 21:40:56 +00:00
|
|
|
newtypes::{CommentId, CommentReportId, CommunityId, LanguageId, LocalUserId, PostId},
|
2022-07-30 03:55:59 +00:00
|
|
|
CommentSortType,
|
2022-05-06 20:55:07 +00:00
|
|
|
ListingType,
|
|
|
|
};
|
2024-01-03 18:39:21 +00:00
|
|
|
use lemmy_db_views::structs::{CommentReportView, CommentView, VoteView};
|
2020-09-01 14:25:34 +00:00
|
|
|
use serde::{Deserialize, Serialize};
|
2023-04-26 04:26:10 +00:00
|
|
|
use serde_with::skip_serializing_none;
|
|
|
|
#[cfg(feature = "full")]
|
|
|
|
use ts_rs::TS;
|
2020-09-01 14:25:34 +00:00
|
|
|
|
2023-04-26 04:26:10 +00:00
|
|
|
#[skip_serializing_none]
|
2024-02-11 05:32:14 +00:00
|
|
|
#[derive(Debug, Serialize, Deserialize, Clone, Default, PartialEq, Eq, Hash)]
|
2023-04-26 04:26:10 +00:00
|
|
|
#[cfg_attr(feature = "full", derive(TS))]
|
|
|
|
#[cfg_attr(feature = "full", ts(export))]
|
2023-05-10 19:20:39 +00:00
|
|
|
/// Create a comment.
|
2020-09-01 14:25:34 +00:00
|
|
|
pub struct CreateComment {
|
|
|
|
pub content: String,
|
2021-03-18 20:25:21 +00:00
|
|
|
pub post_id: PostId,
|
2021-04-15 03:37:51 +00:00
|
|
|
pub parent_id: Option<CommentId>,
|
2022-08-23 21:40:56 +00:00
|
|
|
pub language_id: Option<LanguageId>,
|
2020-09-01 14:25:34 +00:00
|
|
|
}
|
|
|
|
|
2023-04-26 04:26:10 +00:00
|
|
|
#[skip_serializing_none]
|
2024-02-11 05:32:14 +00:00
|
|
|
#[derive(Debug, Serialize, Deserialize, Clone, Default, Copy, PartialEq, Eq, Hash)]
|
2023-04-26 04:26:10 +00:00
|
|
|
#[cfg_attr(feature = "full", derive(TS))]
|
|
|
|
#[cfg_attr(feature = "full", ts(export))]
|
2023-05-10 19:20:39 +00:00
|
|
|
/// Fetch an individual comment.
|
2021-11-23 15:53:48 +00:00
|
|
|
pub struct GetComment {
|
|
|
|
pub id: CommentId,
|
|
|
|
}
|
|
|
|
|
2023-04-26 04:26:10 +00:00
|
|
|
#[skip_serializing_none]
|
2024-02-11 05:32:14 +00:00
|
|
|
#[derive(Debug, Serialize, Deserialize, Clone, Default, PartialEq, Eq, Hash)]
|
2023-04-26 04:26:10 +00:00
|
|
|
#[cfg_attr(feature = "full", derive(TS))]
|
|
|
|
#[cfg_attr(feature = "full", ts(export))]
|
2023-05-10 19:20:39 +00:00
|
|
|
/// Edit a comment.
|
2020-09-01 14:25:34 +00:00
|
|
|
pub struct EditComment {
|
2021-03-18 20:25:21 +00:00
|
|
|
pub comment_id: CommentId,
|
2022-08-17 11:38:52 +00:00
|
|
|
pub content: Option<String>,
|
2022-08-23 21:40:56 +00:00
|
|
|
pub language_id: Option<LanguageId>,
|
2020-09-01 14:25:34 +00:00
|
|
|
}
|
|
|
|
|
2023-04-26 04:26:10 +00:00
|
|
|
#[skip_serializing_none]
|
2024-02-11 05:32:14 +00:00
|
|
|
#[derive(Debug, Serialize, Deserialize, Clone, Copy, Default, PartialEq, Eq, Hash)]
|
2023-04-26 04:26:10 +00:00
|
|
|
#[cfg_attr(feature = "full", derive(TS))]
|
|
|
|
#[cfg_attr(feature = "full", ts(export))]
|
2023-05-10 19:20:39 +00:00
|
|
|
/// Distinguish a comment (IE speak as moderator).
|
2023-02-18 14:46:34 +00:00
|
|
|
pub struct DistinguishComment {
|
|
|
|
pub comment_id: CommentId,
|
|
|
|
pub distinguished: bool,
|
|
|
|
}
|
|
|
|
|
2023-04-26 04:26:10 +00:00
|
|
|
#[skip_serializing_none]
|
2024-02-11 05:32:14 +00:00
|
|
|
#[derive(Debug, Serialize, Deserialize, Clone, Copy, Default, PartialEq, Eq, Hash)]
|
2023-04-26 04:26:10 +00:00
|
|
|
#[cfg_attr(feature = "full", derive(TS))]
|
|
|
|
#[cfg_attr(feature = "full", ts(export))]
|
2023-05-10 19:20:39 +00:00
|
|
|
/// Delete your own comment.
|
2020-09-01 14:25:34 +00:00
|
|
|
pub struct DeleteComment {
|
2021-03-18 20:25:21 +00:00
|
|
|
pub comment_id: CommentId,
|
2020-09-01 14:25:34 +00:00
|
|
|
pub deleted: bool,
|
|
|
|
}
|
|
|
|
|
2023-04-26 04:26:10 +00:00
|
|
|
#[skip_serializing_none]
|
2024-02-11 05:32:14 +00:00
|
|
|
#[derive(Debug, Serialize, Deserialize, Clone, Default, PartialEq, Eq, Hash)]
|
2023-04-26 04:26:10 +00:00
|
|
|
#[cfg_attr(feature = "full", derive(TS))]
|
|
|
|
#[cfg_attr(feature = "full", ts(export))]
|
2023-05-10 19:20:39 +00:00
|
|
|
/// Remove a comment (only doable by mods).
|
2020-09-01 14:25:34 +00:00
|
|
|
pub struct RemoveComment {
|
2021-03-18 20:25:21 +00:00
|
|
|
pub comment_id: CommentId,
|
2020-09-01 14:25:34 +00:00
|
|
|
pub removed: bool,
|
|
|
|
pub reason: Option<String>,
|
|
|
|
}
|
|
|
|
|
2024-02-11 05:32:14 +00:00
|
|
|
#[derive(Debug, Serialize, Deserialize, Clone, Copy, Default, PartialEq, Eq, Hash)]
|
2023-04-26 04:26:10 +00:00
|
|
|
#[cfg_attr(feature = "full", derive(TS))]
|
|
|
|
#[cfg_attr(feature = "full", ts(export))]
|
2023-05-10 19:20:39 +00:00
|
|
|
/// Save / bookmark a comment.
|
2020-09-01 14:25:34 +00:00
|
|
|
pub struct SaveComment {
|
2021-03-18 20:25:21 +00:00
|
|
|
pub comment_id: CommentId,
|
2020-09-01 14:25:34 +00:00
|
|
|
pub save: bool,
|
|
|
|
}
|
|
|
|
|
2023-04-26 04:26:10 +00:00
|
|
|
#[skip_serializing_none]
|
2021-12-06 14:54:47 +00:00
|
|
|
#[derive(Debug, Serialize, Deserialize, Clone)]
|
2023-04-26 04:26:10 +00:00
|
|
|
#[cfg_attr(feature = "full", derive(TS))]
|
|
|
|
#[cfg_attr(feature = "full", ts(export))]
|
2023-05-10 19:20:39 +00:00
|
|
|
/// A comment response.
|
2020-09-01 14:25:34 +00:00
|
|
|
pub struct CommentResponse {
|
2020-12-15 19:39:18 +00:00
|
|
|
pub comment_view: CommentView,
|
2021-03-18 20:25:21 +00:00
|
|
|
pub recipient_ids: Vec<LocalUserId>,
|
2020-09-01 14:25:34 +00:00
|
|
|
}
|
|
|
|
|
2024-02-11 05:32:14 +00:00
|
|
|
#[derive(Debug, Serialize, Deserialize, Clone, Copy, Default, PartialEq, Eq, Hash)]
|
2023-04-26 04:26:10 +00:00
|
|
|
#[cfg_attr(feature = "full", derive(TS))]
|
|
|
|
#[cfg_attr(feature = "full", ts(export))]
|
2023-05-10 19:20:39 +00:00
|
|
|
/// Like a comment.
|
2020-09-01 14:25:34 +00:00
|
|
|
pub struct CreateCommentLike {
|
2021-03-18 20:25:21 +00:00
|
|
|
pub comment_id: CommentId,
|
2023-05-10 19:20:39 +00:00
|
|
|
/// Must be -1, 0, or 1 .
|
2020-09-01 14:25:34 +00:00
|
|
|
pub score: i16,
|
|
|
|
}
|
|
|
|
|
2023-04-26 04:26:10 +00:00
|
|
|
#[skip_serializing_none]
|
2024-02-11 05:32:14 +00:00
|
|
|
#[derive(Debug, Serialize, Deserialize, Clone, Default, PartialEq, Eq, Hash)]
|
2023-04-26 04:26:10 +00:00
|
|
|
#[cfg_attr(feature = "full", derive(TS))]
|
|
|
|
#[cfg_attr(feature = "full", ts(export))]
|
2023-05-10 19:20:39 +00:00
|
|
|
/// Get a list of comments.
|
2020-09-01 14:25:34 +00:00
|
|
|
pub struct GetComments {
|
2022-05-06 20:55:07 +00:00
|
|
|
pub type_: Option<ListingType>,
|
2022-07-30 03:55:59 +00:00
|
|
|
pub sort: Option<CommentSortType>,
|
|
|
|
pub max_depth: Option<i32>,
|
2020-09-01 14:25:34 +00:00
|
|
|
pub page: Option<i64>,
|
|
|
|
pub limit: Option<i64>,
|
2021-03-18 20:25:21 +00:00
|
|
|
pub community_id: Option<CommunityId>,
|
2020-09-15 19:26:47 +00:00
|
|
|
pub community_name: Option<String>,
|
2022-07-30 03:55:59 +00:00
|
|
|
pub post_id: Option<PostId>,
|
|
|
|
pub parent_id: Option<CommentId>,
|
2021-04-15 03:37:51 +00:00
|
|
|
pub saved_only: Option<bool>,
|
2023-08-08 09:40:28 +00:00
|
|
|
pub liked_only: Option<bool>,
|
|
|
|
pub disliked_only: Option<bool>,
|
2020-09-01 14:25:34 +00:00
|
|
|
}
|
|
|
|
|
2022-05-06 20:55:07 +00:00
|
|
|
#[derive(Debug, Serialize, Deserialize, Clone)]
|
2023-04-26 04:26:10 +00:00
|
|
|
#[cfg_attr(feature = "full", derive(TS))]
|
|
|
|
#[cfg_attr(feature = "full", ts(export))]
|
2023-05-10 19:20:39 +00:00
|
|
|
/// The comment list response.
|
2020-09-01 14:25:34 +00:00
|
|
|
pub struct GetCommentsResponse {
|
|
|
|
pub comments: Vec<CommentView>,
|
|
|
|
}
|
2020-10-25 02:59:13 +00:00
|
|
|
|
2022-05-06 20:55:07 +00:00
|
|
|
#[derive(Debug, Serialize, Deserialize, Clone, Default)]
|
2023-04-26 04:26:10 +00:00
|
|
|
#[cfg_attr(feature = "full", derive(TS))]
|
|
|
|
#[cfg_attr(feature = "full", ts(export))]
|
2023-05-10 19:20:39 +00:00
|
|
|
/// Report a comment.
|
2020-10-25 02:59:13 +00:00
|
|
|
pub struct CreateCommentReport {
|
2021-03-18 20:25:21 +00:00
|
|
|
pub comment_id: CommentId,
|
2020-10-25 02:59:13 +00:00
|
|
|
pub reason: String,
|
|
|
|
}
|
|
|
|
|
2021-12-06 14:54:47 +00:00
|
|
|
#[derive(Debug, Serialize, Deserialize, Clone)]
|
2023-04-26 04:26:10 +00:00
|
|
|
#[cfg_attr(feature = "full", derive(TS))]
|
|
|
|
#[cfg_attr(feature = "full", ts(export))]
|
2023-05-10 19:20:39 +00:00
|
|
|
/// The comment report response.
|
2021-09-28 10:36:17 +00:00
|
|
|
pub struct CommentReportResponse {
|
|
|
|
pub comment_report_view: CommentReportView,
|
2020-10-25 02:59:13 +00:00
|
|
|
}
|
|
|
|
|
2024-02-11 05:32:14 +00:00
|
|
|
#[derive(Debug, Serialize, Deserialize, Clone, Copy, Default, PartialEq, Eq, Hash)]
|
2023-04-26 04:26:10 +00:00
|
|
|
#[cfg_attr(feature = "full", derive(TS))]
|
|
|
|
#[cfg_attr(feature = "full", ts(export))]
|
2023-05-10 19:20:39 +00:00
|
|
|
/// Resolve a comment report (only doable by mods).
|
2020-10-25 02:59:13 +00:00
|
|
|
pub struct ResolveCommentReport {
|
2021-09-28 10:36:17 +00:00
|
|
|
pub report_id: CommentReportId,
|
2020-10-25 02:59:13 +00:00
|
|
|
pub resolved: bool,
|
|
|
|
}
|
|
|
|
|
2023-04-26 04:26:10 +00:00
|
|
|
#[skip_serializing_none]
|
2024-02-11 05:32:14 +00:00
|
|
|
#[derive(Debug, Serialize, Deserialize, Clone, Copy, Default, PartialEq, Eq, Hash)]
|
2023-04-26 04:26:10 +00:00
|
|
|
#[cfg_attr(feature = "full", derive(TS))]
|
|
|
|
#[cfg_attr(feature = "full", ts(export))]
|
2023-05-10 19:20:39 +00:00
|
|
|
/// List comment reports.
|
2020-10-25 02:59:13 +00:00
|
|
|
pub struct ListCommentReports {
|
|
|
|
pub page: Option<i64>,
|
|
|
|
pub limit: Option<i64>,
|
2021-09-28 10:36:17 +00:00
|
|
|
/// Only shows the unresolved reports
|
|
|
|
pub unresolved_only: Option<bool>,
|
2020-11-26 12:28:58 +00:00
|
|
|
/// if no community is given, it returns reports for all communities moderated by the auth user
|
2021-09-28 10:36:17 +00:00
|
|
|
pub community_id: Option<CommunityId>,
|
2020-10-25 02:59:13 +00:00
|
|
|
}
|
|
|
|
|
2022-05-06 20:55:07 +00:00
|
|
|
#[derive(Debug, Serialize, Deserialize, Clone)]
|
2023-04-26 04:26:10 +00:00
|
|
|
#[cfg_attr(feature = "full", derive(TS))]
|
|
|
|
#[cfg_attr(feature = "full", ts(export))]
|
2023-05-10 19:20:39 +00:00
|
|
|
/// The comment report list response.
|
2020-10-25 02:59:13 +00:00
|
|
|
pub struct ListCommentReportsResponse {
|
2021-09-28 10:36:17 +00:00
|
|
|
pub comment_reports: Vec<CommentReportView>,
|
2020-10-25 02:59:13 +00:00
|
|
|
}
|
2024-01-03 18:39:21 +00:00
|
|
|
|
|
|
|
#[skip_serializing_none]
|
2024-02-11 05:32:14 +00:00
|
|
|
#[derive(Debug, Serialize, Deserialize, Clone, Copy, Default, PartialEq, Eq, Hash)]
|
2024-01-03 18:39:21 +00:00
|
|
|
#[cfg_attr(feature = "full", derive(TS))]
|
|
|
|
#[cfg_attr(feature = "full", ts(export))]
|
|
|
|
/// List comment likes. Admins-only.
|
|
|
|
pub struct ListCommentLikes {
|
|
|
|
pub comment_id: CommentId,
|
|
|
|
pub page: Option<i64>,
|
|
|
|
pub limit: Option<i64>,
|
|
|
|
}
|
|
|
|
|
|
|
|
#[derive(Debug, Serialize, Deserialize, Clone)]
|
|
|
|
#[cfg_attr(feature = "full", derive(TS))]
|
|
|
|
#[cfg_attr(feature = "full", ts(export))]
|
|
|
|
/// The comment likes response
|
|
|
|
pub struct ListCommentLikesResponse {
|
|
|
|
pub comment_likes: Vec<VoteView>,
|
|
|
|
}
|