From 00d68cf3b59e998cf8d2029a6fe46c1550d185b0 Mon Sep 17 00:00:00 2001 From: Cobblestone Date: Sun, 26 Nov 2023 16:07:04 -0500 Subject: [PATCH] fix comments? --- routes/comments.py | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/routes/comments.py b/routes/comments.py index 9ebf0c6..627cbc9 100644 --- a/routes/comments.py +++ b/routes/comments.py @@ -249,7 +249,7 @@ def get_comment(id: int) -> tuple[dict[str, Any] | str, int]: conn = util.make_connection() comment = util.exec_query( conn, - "select rowid, message, author, sent from comments where rowid = :id and parent_id is null order by sent desc", + "select rowid, message, author, sent, parent_id from comments where rowid = :id order by sent desc", id=id, ).all() @@ -270,9 +270,12 @@ def get_comment(id: int) -> tuple[dict[str, Any] | str, int]: if not (usr.id == comment[2] or usr.role in ["admin", "moderator"]): return "This isn't your comment.", 403 - - util.exec_query(conn, "delete from comments where rowid = :id", id=id) - util.exec_query(conn, "delete from comments where parent_id = :id", id=id) + + if comment[4] is None: + util.exec_query(conn, "delete from comments where rowid = :id", id=id) + util.exec_query(conn, "delete from comments where parent_id = :id", id=id) + else: + util.exec_query(conn, "delete from comments where rowid = :id", id=id) conn.commit()