Restoring Deleted Messages?

Hi everyone,

I am an auditor at a site with Discourse engine. One of the members deleted about 1300 messages. The system automatically puts the responses to this message at the end of the topic. Do we have a batch restore facility?

2 Likes

If you’re self-hosted you can do it from the rails console. If you’re hosted, you can ask support.

There might be some hints over in Administrative Bulk Operations.

Something like

t=Topic.all.with_deleted.where("deleted_at is not null").where(user_id: 123)
t.update_all(deleted_at: nil, deleted_by_id: nil)

But I think you will then need to run something else to update some other tables.

5 Likes

Can you describe how they did that, exactly? In a default Discourse install, a regular user is rate limited in how much they can delete and deletions take 24 hours to take effect.

3 Likes

I think he deleted five posts every day.

4 Likes

I see. These are soft-deletes so you should be able to undo them, either via the UI, or at the command line if you SSH into the server.

You can turn down the number of allowed deletions per day in your admin site settings to prevent this from happening in the future; there’s some discussion about allowing a zero in that setting so all deletions are prevented.

5 Likes

Can we make sure that zero setting gets supported next week @sam? And update the copy around the setting so people know it is there.

3 Likes

Done via:

Setting either max_post_deletions_per_minute or max_post_deletions_per_day to 0 will disable self deletion of posts.

4 Likes