Skip to content

Commit

Permalink
fix comments?
Browse files Browse the repository at this point in the history
  • Loading branch information
HoodieRocks committed Nov 26, 2023
1 parent c760cf6 commit 00d68cf
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions routes/comments.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()

Expand 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()

Expand Down

0 comments on commit 00d68cf

Please sign in to comment.