use lemmy_api_common::{ comment::{CommentResponse, CreateComment, CreateCommentLike, DeleteComment, EditComment}, lemmy_db_schema::newtypes::{CommentId, PostId}, }; use crate::settings; pub fn create_comment( post_id: i32, content: String, parent_id: Option, ) -> Result { let params = CreateComment { post_id: PostId(post_id), content, parent_id: parent_id.map(CommentId), auth: settings::get_current_account().jwt.unwrap(), ..Default::default() }; super::post("/comment", ¶ms) } // see posts.rs for possible score parameters pub fn like_comment(comment_id: CommentId, score: i16) -> Result { let params = CreateCommentLike { comment_id, score, auth: settings::get_current_account().jwt.unwrap(), }; super::post("/comment/like", ¶ms) } pub fn edit_comment(body: String, comment_id: i32) -> Result { let params = EditComment { content: Some(body), comment_id: CommentId(comment_id), auth: settings::get_current_account().jwt.unwrap(), ..Default::default() }; super::put("/post", ¶ms) } pub fn delete_comment(comment_id: CommentId) -> Result { let params = DeleteComment { comment_id, deleted: true, auth: settings::get_current_account().jwt.unwrap(), }; super::post("/comment/delete", ¶ms) }