Working comment route fully implemented

This commit is contained in:
Imbus 2024-03-06 08:05:23 +01:00
parent 32ff43e87c
commit d0e5b57006
3 changed files with 14 additions and 17 deletions

View file

@ -24,6 +24,11 @@ pub async fn get_comments(
let comments = db_get_comments(&state.pool, post_id, limit, offset).await;
if comments.is_empty() {
info!("No comments found for post {}", post_id);
return Ok(HttpResponse::NotFound().json("No comments found"));
}
Ok(HttpResponse::Ok().json(comments))
}
@ -60,14 +65,7 @@ pub async fn new_comment(
info!("Creating a new comment {:?}", &data);
let success = db_new_comment(
&state.pool,
data.parent_post_id,
data.parent_comment_id,
userid,
&content,
)
.await;
let success = db_new_comment(&state.pool, data.parent_post_id, userid, &content).await;
match success {
true => {