From a7ed2707d0e6207b956fb4242b90132bf02f0ff1 Mon Sep 17 00:00:00 2001 From: Aevann Date: Mon, 4 Dec 2023 15:29:57 +0200 Subject: [PATCH] dedup --- files/routes/admin.py | 11 ++--------- 1 file changed, 2 insertions(+), 9 deletions(-) diff --git a/files/routes/admin.py b/files/routes/admin.py index ba69a3d7a8..b2e9384555 100644 --- a/files/routes/admin.py +++ b/files/routes/admin.py @@ -1553,11 +1553,7 @@ def sticky_comment(cid, v): message = f"@{v.username} (a site admin) has pinned your [comment]({comment.shortlink})" send_repeatable_notification(comment.author_id, message) - c = comment - while c.level > 2: - c = c.parent_comment - c.stickied_child_id = comment.id - g.db.add(c) + comment.pin_parents() return {"message": "Comment pinned!"} @@ -1590,10 +1586,7 @@ def unsticky_comment(cid, v): message = f"@{v.username} (a site admin) has unpinned your [comment]({comment.shortlink})" send_repeatable_notification(comment.author_id, message) - cleanup = g.db.query(Comment).filter_by(stickied_child_id=comment.id).all() - for c in cleanup: - c.stickied_child_id = None - g.db.add(c) + comment.unpin_parents() return {"message": "Comment unpinned!"}