Delete post fix, proper cascading on comments

This commit is contained in:
Imbus 2024-03-22 23:20:47 +01:00
parent 61ab9e072e
commit d2eac68638
2 changed files with 10 additions and 3 deletions

View file

@ -153,7 +153,14 @@ pub async fn delete_post(
.await;
match q {
Ok(_) => Ok(HttpResponse::Ok().json("Deleted")),
Ok(q) => {
// Does this include cascading deletes?
if q.rows_affected() == 1 {
Ok(HttpResponse::Ok().json("Deleted"))
} else {
Ok(HttpResponse::Forbidden().json("Forbidden"))
}
}
Err(e) => {
info!("Error deleting post: {}", e);
Ok(HttpResponse::InternalServerError().json("Error"))