Merge pull request 'Show who deleted a post' (#422) from h3ndrik/pyfedi:deleted_by into main

Reviewed-on: https://codeberg.org/rimu/pyfedi/pulls/422
This commit is contained in:
rimu 2025-01-13 20:41:30 +00:00
commit 3997567f2f

View file

@ -43,6 +43,9 @@ def show_post(post_id: int):
if community.banned or post.deleted: if community.banned or post.deleted:
if current_user.is_anonymous or not (current_user.is_authenticated and (current_user.is_admin() or current_user.is_staff())): if current_user.is_anonymous or not (current_user.is_authenticated and (current_user.is_admin() or current_user.is_staff())):
abort(404) abort(404)
else:
if post.deleted_by == post.user_id:
flash(_('This post has been deleted by the author and is only visible to staff and admins.'), 'warning')
else: else:
flash(_('This post has been deleted and is only visible to staff and admins.'), 'warning') flash(_('This post has been deleted and is only visible to staff and admins.'), 'warning')
@ -390,7 +393,10 @@ def continue_discussion(post_id, comment_id):
if current_user.is_anonymous or not (current_user.is_authenticated and (current_user.is_admin() or current_user.is_staff())): if current_user.is_anonymous or not (current_user.is_authenticated and (current_user.is_admin() or current_user.is_staff())):
abort(404) abort(404)
else: else:
flash(_('This comment has been deleted and is only visible to staff and admins.'), 'warning') if post.deleted_by == post.user_id:
flash(_('This post has been deleted by the author and is only visible to staff and admins.'), 'warning')
else:
flash(_('This post has been deleted and is only visible to staff and admins.'), 'warning')
mods = post.community.moderators() mods = post.community.moderators()
is_moderator = current_user.is_authenticated and any(mod.user_id == current_user.id for mod in mods) is_moderator = current_user.is_authenticated and any(mod.user_id == current_user.id for mod in mods)