FEATURE: Allow admins to permanently delete posts and topics (PR #14406)

Sometimes administrators want to permanently delete posts and topics from the database. To make sure that this is done for a good reasons, administrators can do this only after one minute has passed since the post was deleted or immediately if another administrator does it.

What is left to do:

  • hide functionality under a site setting
  • change the interval from 1 minute to more
  • add client tests
  • add server tests


Just curious why we do not have to use can_edit_post here.

I’m wondering if we have to call guardian.ensure_can_delete! above if we’re already calling the guardian method here.

Oops sorry for the early review. I didn’t notice this was a draft.

I don’t think the guardian is the right place for the _reason method.

Also, if you call the cannot_permanently_delete_post_reason method, that’s because you’ve already called the cannot_permanently_delete_post? and it returned true. So you don’t need to repeat all the tests, only the ones you want to display a message for.

Ditto ^^

We do the same thing for cannot_delete_category_reason. Should I move that one too?

I know you just moved this method, but what happens if topic_count == 0?

I mean, does the calling code always expect a reason?

The way I see these _reason methods is that they return a correct result only if the user cannot delete the object, but they should be. Looking at can_delete_category? and this method, topic_count == 0 is a possibility only if the user is not an admin and cannot edit the category.

The calling code is a serializer. The reason is displayed by the client in a tooltip, but only if it exists.


A few questions about this:

  • Does it also work for private messages?
  • Does an attachment get deleted from the server, not just the reference to it?
  • Is this setting enabled or disabled in site settings by default?

A lot of people are gonna be loving you now :slight_smile:

thank you