From 584da46d22a8c3fe004476d98fc0fc0865297d77 Mon Sep 17 00:00:00 2001 From: Aevann Date: Wed, 13 Nov 2024 00:42:55 +0200 Subject: [PATCH] fix this "if a user pins a comment on their wall, then that comment gets janny-removed or the account shadowbanned, the wall owner is unable to pin another comment" --- files/routes/admin.py | 5 +++++ files/routes/comments.py | 3 ++- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/files/routes/admin.py b/files/routes/admin.py index 1772b23d9..518893050 100644 --- a/files/routes/admin.py +++ b/files/routes/admin.py @@ -1612,6 +1612,11 @@ def remove_comment(c_id, v): comment.is_banned = True + if comment.pinned: + comment.pinned = None + comment.pinned_utc = None + comment.unpin_parents() + for media_usage in comment.media_usages: media_usage.removed_utc = time.time() g.db.add(media_usage) diff --git a/files/routes/comments.py b/files/routes/comments.py index 2c6bc2184..5b43c4dcf 100644 --- a/files/routes/comments.py +++ b/files/routes/comments.py @@ -550,9 +550,10 @@ def pin_comment_wall_owner(cid, v): if v.id != comment.wall_user_id: stop(403, "You can't pin comments on the walls of other users!") - existing = g.db.query(Comment.id).filter( + existing = g.db.query(Comment.id).join(Comment.author).filter( Comment.wall_user_id == v.id, Comment.pinned.like('% (Wall Owner)'), + User.shadowbanned == None, ).one_or_none() if existing: