2021-03-18 14:25:21 -06:00
|
|
|
use lemmy_db_schema::{CommentId, CommunityId, LocalUserId, PostId};
|
2020-12-21 09:30:34 -07:00
|
|
|
use lemmy_db_views::{comment_report_view::CommentReportView, comment_view::CommentView};
|
2020-09-01 08:25:34 -06:00
|
|
|
use serde::{Deserialize, Serialize};
|
|
|
|
|
2020-09-03 13:45:12 -06:00
|
|
|
#[derive(Deserialize)]
|
2020-09-01 08:25:34 -06:00
|
|
|
pub struct CreateComment {
|
|
|
|
pub content: String,
|
2021-03-18 14:25:21 -06:00
|
|
|
pub parent_id: Option<CommentId>,
|
|
|
|
pub post_id: PostId,
|
2020-09-01 08:25:34 -06:00
|
|
|
pub form_id: Option<String>,
|
|
|
|
pub auth: String,
|
|
|
|
}
|
|
|
|
|
2020-09-03 13:45:12 -06:00
|
|
|
#[derive(Deserialize)]
|
2020-09-01 08:25:34 -06:00
|
|
|
pub struct EditComment {
|
|
|
|
pub content: String,
|
2021-03-18 14:25:21 -06:00
|
|
|
pub comment_id: CommentId,
|
2020-09-01 08:25:34 -06:00
|
|
|
pub form_id: Option<String>,
|
|
|
|
pub auth: String,
|
|
|
|
}
|
|
|
|
|
2020-09-03 13:45:12 -06:00
|
|
|
#[derive(Deserialize)]
|
2020-09-01 08:25:34 -06:00
|
|
|
pub struct DeleteComment {
|
2021-03-18 14:25:21 -06:00
|
|
|
pub comment_id: CommentId,
|
2020-09-01 08:25:34 -06:00
|
|
|
pub deleted: bool,
|
|
|
|
pub auth: String,
|
|
|
|
}
|
|
|
|
|
2020-09-03 13:45:12 -06:00
|
|
|
#[derive(Deserialize)]
|
2020-09-01 08:25:34 -06:00
|
|
|
pub struct RemoveComment {
|
2021-03-18 14:25:21 -06:00
|
|
|
pub comment_id: CommentId,
|
2020-09-01 08:25:34 -06:00
|
|
|
pub removed: bool,
|
|
|
|
pub reason: Option<String>,
|
|
|
|
pub auth: String,
|
|
|
|
}
|
|
|
|
|
2020-09-03 13:45:12 -06:00
|
|
|
#[derive(Deserialize)]
|
2020-09-01 08:25:34 -06:00
|
|
|
pub struct MarkCommentAsRead {
|
2021-03-18 14:25:21 -06:00
|
|
|
pub comment_id: CommentId,
|
2020-09-01 08:25:34 -06:00
|
|
|
pub read: bool,
|
|
|
|
pub auth: String,
|
|
|
|
}
|
|
|
|
|
2020-09-03 13:45:12 -06:00
|
|
|
#[derive(Deserialize)]
|
2020-09-01 08:25:34 -06:00
|
|
|
pub struct SaveComment {
|
2021-03-18 14:25:21 -06:00
|
|
|
pub comment_id: CommentId,
|
2020-09-01 08:25:34 -06:00
|
|
|
pub save: bool,
|
|
|
|
pub auth: String,
|
|
|
|
}
|
|
|
|
|
2020-09-03 13:45:12 -06:00
|
|
|
#[derive(Serialize, Clone)]
|
2020-09-01 08:25:34 -06:00
|
|
|
pub struct CommentResponse {
|
2020-12-15 12:39:18 -07:00
|
|
|
pub comment_view: CommentView,
|
2021-03-18 14:25:21 -06:00
|
|
|
pub recipient_ids: Vec<LocalUserId>,
|
2020-12-19 18:10:47 -07:00
|
|
|
pub form_id: Option<String>, // An optional front end ID, to tell which is coming back
|
2020-09-01 08:25:34 -06:00
|
|
|
}
|
|
|
|
|
2020-09-03 13:45:12 -06:00
|
|
|
#[derive(Deserialize)]
|
2020-09-01 08:25:34 -06:00
|
|
|
pub struct CreateCommentLike {
|
2021-03-18 14:25:21 -06:00
|
|
|
pub comment_id: CommentId,
|
2020-09-01 08:25:34 -06:00
|
|
|
pub score: i16,
|
|
|
|
pub auth: String,
|
|
|
|
}
|
|
|
|
|
2020-09-03 13:45:12 -06:00
|
|
|
#[derive(Deserialize)]
|
2020-09-01 08:25:34 -06:00
|
|
|
pub struct GetComments {
|
|
|
|
pub type_: String,
|
|
|
|
pub sort: String,
|
|
|
|
pub page: Option<i64>,
|
|
|
|
pub limit: Option<i64>,
|
2021-03-18 14:25:21 -06:00
|
|
|
pub community_id: Option<CommunityId>,
|
2020-09-15 13:26:47 -06:00
|
|
|
pub community_name: Option<String>,
|
2021-03-22 08:39:54 -06:00
|
|
|
pub saved_only: bool,
|
2020-09-01 08:25:34 -06:00
|
|
|
pub auth: Option<String>,
|
|
|
|
}
|
|
|
|
|
2020-09-03 13:45:12 -06:00
|
|
|
#[derive(Serialize)]
|
2020-09-01 08:25:34 -06:00
|
|
|
pub struct GetCommentsResponse {
|
|
|
|
pub comments: Vec<CommentView>,
|
|
|
|
}
|
2020-10-24 20:59:13 -06:00
|
|
|
|
|
|
|
#[derive(Serialize, Deserialize)]
|
|
|
|
pub struct CreateCommentReport {
|
2021-03-18 14:25:21 -06:00
|
|
|
pub comment_id: CommentId,
|
2020-10-24 20:59:13 -06:00
|
|
|
pub reason: String,
|
|
|
|
pub auth: String,
|
|
|
|
}
|
|
|
|
|
|
|
|
#[derive(Serialize, Deserialize, Clone)]
|
|
|
|
pub struct CreateCommentReportResponse {
|
|
|
|
pub success: bool,
|
|
|
|
}
|
|
|
|
|
|
|
|
#[derive(Serialize, Deserialize, Debug)]
|
|
|
|
pub struct ResolveCommentReport {
|
|
|
|
pub report_id: i32,
|
|
|
|
pub resolved: bool,
|
|
|
|
pub auth: String,
|
|
|
|
}
|
|
|
|
|
|
|
|
#[derive(Serialize, Deserialize, Clone, Debug)]
|
|
|
|
pub struct ResolveCommentReportResponse {
|
2020-12-19 18:10:47 -07:00
|
|
|
// TODO this should probably return the view
|
2020-10-24 20:59:13 -06:00
|
|
|
pub report_id: i32,
|
|
|
|
pub resolved: bool,
|
|
|
|
}
|
|
|
|
|
|
|
|
#[derive(Serialize, Deserialize, Debug)]
|
|
|
|
pub struct ListCommentReports {
|
|
|
|
pub page: Option<i64>,
|
|
|
|
pub limit: Option<i64>,
|
2020-11-26 05:28:58 -07:00
|
|
|
/// if no community is given, it returns reports for all communities moderated by the auth user
|
2021-03-18 14:25:21 -06:00
|
|
|
pub community: Option<CommunityId>,
|
2020-10-24 20:59:13 -06:00
|
|
|
pub auth: String,
|
|
|
|
}
|
|
|
|
|
2020-12-16 20:03:03 -07:00
|
|
|
#[derive(Serialize, Clone, Debug)]
|
2020-10-24 20:59:13 -06:00
|
|
|
pub struct ListCommentReportsResponse {
|
|
|
|
pub comments: Vec<CommentReportView>,
|
|
|
|
}
|