mirror of
https://codeberg.org/rimu/pyfedi
synced 2025-01-23 19:36:56 -08:00
populate deleted_by field
This commit is contained in:
parent
377d07a67e
commit
f1ddbcf008
4 changed files with 10 additions and 0 deletions
|
@ -1315,6 +1315,7 @@ def delete_post_or_comment_task(user_ap_id, community_ap_id, to_be_deleted_ap_id
|
|||
to_delete.deleted = True
|
||||
community.post_count -= 1
|
||||
to_delete.author.post_count -= 1
|
||||
to_delete.deleted_by = deletor.id
|
||||
db.session.commit()
|
||||
if to_delete.author.id != deletor.id:
|
||||
add_to_modlog_activitypub('delete_post', deletor, community_id=community.id,
|
||||
|
@ -1329,6 +1330,7 @@ def delete_post_or_comment_task(user_ap_id, community_ap_id, to_be_deleted_ap_id
|
|||
to_delete.delete_dependencies()
|
||||
to_delete.deleted = True
|
||||
to_delete.author.post_reply_count -= 1
|
||||
to_delete.deleted_by = deletor.id
|
||||
db.session.commit()
|
||||
if to_delete.author.id != deletor.id:
|
||||
add_to_modlog_activitypub('delete_post_reply', deletor, community_id=community.id,
|
||||
|
@ -1354,6 +1356,7 @@ def restore_post_or_comment_task(object_json):
|
|||
if isinstance(to_restore, Post):
|
||||
# TODO: restore_dependencies()
|
||||
to_restore.deleted = False
|
||||
to_restore.deleted_by = None
|
||||
community.post_count += 1
|
||||
to_restore.author.post_count += 1
|
||||
db.session.commit()
|
||||
|
|
|
@ -1206,6 +1206,7 @@ def admin_user_delete(user_id):
|
|||
|
||||
user.banned = True # Unsubscribing everyone could take a long time so until that is completed hide this user from the UI by banning it.
|
||||
user.last_active = utcnow()
|
||||
user.deleted_by = current_user.id
|
||||
db.session.commit()
|
||||
|
||||
if user.is_local():
|
||||
|
|
|
@ -1016,6 +1016,7 @@ def post_delete_post(community: Community, post: Post, user_id: int, federate_al
|
|||
ocp.cross_posts.remove(post.id)
|
||||
post.delete_dependencies()
|
||||
post.deleted = True
|
||||
post.deleted_by = user_id
|
||||
post.author.post_count -= 1
|
||||
community.post_count -= 1
|
||||
if hasattr(g, 'site'): # g.site is invalid when running from cli
|
||||
|
@ -1606,6 +1607,7 @@ def post_reply_delete(post_id: int, comment_id: int):
|
|||
if not post_reply.author.bot:
|
||||
post.reply_count -= 1
|
||||
post_reply.author.post_reply_count -= 1
|
||||
post_reply.deleted_by = current_user.id
|
||||
db.session.commit()
|
||||
flash(_('Comment deleted.'))
|
||||
# federate delete
|
||||
|
|
|
@ -667,6 +667,7 @@ def delete_profile(actor):
|
|||
else:
|
||||
user.banned = True
|
||||
user.deleted = True
|
||||
user.deleted_by = current_user.id
|
||||
user.delete_dependencies()
|
||||
db.session.commit()
|
||||
|
||||
|
@ -728,6 +729,7 @@ def delete_account():
|
|||
# to verify the deletes, remote servers will GET /u/<actor> so we can't fully delete the account until the POSTs are done
|
||||
current_user.banned = True
|
||||
current_user.email = f'deleted_{current_user.id}@deleted.com'
|
||||
current_user.deleted_by = current_user.id
|
||||
db.session.commit()
|
||||
|
||||
if current_app.debug:
|
||||
|
@ -803,10 +805,12 @@ def ban_purge_profile(actor):
|
|||
|
||||
# federate deletion
|
||||
if user.is_local():
|
||||
user.deleted_by = current_user.id
|
||||
purge_user_then_delete(user.id)
|
||||
flash(f'{actor} has been banned, deleted and all their content deleted. This might take a few minutes.')
|
||||
else:
|
||||
user.deleted = True
|
||||
user.deleted_by = current_user.id
|
||||
user.delete_dependencies()
|
||||
user.purge_content()
|
||||
db.session.commit()
|
||||
|
|
Loading…
Add table
Reference in a new issue