mirror of
https://codeberg.org/rimu/pyfedi
synced 2025-01-23 19:36:56 -08:00
also delete replies to deleted comments
This commit is contained in:
parent
2f4f56649e
commit
a9f4fff576
1 changed files with 10 additions and 1 deletions
|
@ -838,9 +838,11 @@ class User(UserMixin, db.Model):
|
|||
post.delete_dependencies()
|
||||
post.flush_cache()
|
||||
db.session.delete(post)
|
||||
db.session.commit()
|
||||
post_replies = PostReply.query.filter_by(user_id=self.id).all()
|
||||
for reply in post_replies:
|
||||
reply.body = reply.body_html = ''
|
||||
reply.delete_dependencies()
|
||||
db.session.delete(reply)
|
||||
db.session.commit()
|
||||
|
||||
def mention_tag(self):
|
||||
|
@ -1018,6 +1020,10 @@ class PostReply(db.Model):
|
|||
return parent.author.profile_id()
|
||||
|
||||
def delete_dependencies(self):
|
||||
for child_reply in self.child_replies():
|
||||
child_reply.delete_dependencies()
|
||||
db.session.delete(child_reply)
|
||||
|
||||
db.session.query(Report).filter(Report.suspect_post_reply_id == self.id).delete()
|
||||
db.session.execute(text('DELETE FROM post_reply_vote WHERE post_reply_id = :post_reply_id'),
|
||||
{'post_reply_id': self.id})
|
||||
|
@ -1025,6 +1031,9 @@ class PostReply(db.Model):
|
|||
file = File.query.get(self.image_id)
|
||||
file.delete_from_disk()
|
||||
|
||||
def child_replies(self):
|
||||
return PostReply.query.filter_by(parent_id=self.id).all()
|
||||
|
||||
def has_replies(self):
|
||||
reply = PostReply.query.filter_by(parent_id=self.id).first()
|
||||
return reply is not None
|
||||
|
|
Loading…
Reference in a new issue