From df2dc6e0204d10f0fc56b442e847d74266cfd7b4 Mon Sep 17 00:00:00 2001 From: freamon Date: Fri, 18 Oct 2024 08:20:18 +0000 Subject: [PATCH] post-reply soft-deletion: keep current behaviour by not hard-deleting replies that have their own replies --- app/cli.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/app/cli.py b/app/cli.py index a42783b9..4b22c811 100644 --- a/app/cli.py +++ b/app/cli.py @@ -195,7 +195,8 @@ def register(app): for post_reply in PostReply.query.filter(PostReply.deleted == True, PostReply.posted_at < utcnow() - timedelta(days=7)).all(): post_reply.delete_dependencies() - db.session.delete(post_reply) + if not post_reply.has_replies(): + db.session.delete(post_reply) db.session.commit() for post in Post.query.filter(Post.deleted == True,