Bulk un-deletion

Continuing the discussion from Best way to temporarily remove public access to a user's topics?:

Would it be possible to enable a bulk un-delete selector in the /u/username/deleted-posts list? From what I can tell it would require a technically very challenging and potentially dangerous SQL/rails script to undelete them programatically.

For this feature to be most useful it would be best to differentiate between deleted topics and deleted replies. Maybe the existing /u/username/deleted-posts URL could be maintained, and then add to that /u/username/deleted-posts/topics and /u/username/deleted-posts/replies .

2 Likes

The topics are already deleted, and I don’t have an estimate for when the user might request restoration of the topics, so I guess I can wait for bulk un-deletion to be implemented. I don’t think I’m the only one that would find it useful, there are quite a few posts here requesting help for doing so.

This also looks like a potentially easier and safer way to programmatically un-delete, assuming I can figure out how to generate the list of the user’s deleted topic IDs:

This will find deleted topics created by user_id 1.

dts=Topic.with_deleted.where(user_id: 1).where("deleted_at is not null");
dts.pluck(:deleted_at, :id)
dps=Post.with_deleted.where(user_id: 1).where("deleted_at is not null");
dbs.pluck(:deleted_at, :id)

And it looks like you can un-delete posts with something like

dp=dps.first
dp.deleted_at=nil
dp.deleted_by=nil
dp.save

And you’d do something similar for topics.

If it comes time to un-delete the stuff, the above should be enough for someone who knows a tiny bit about rails to be able to un-delete them all.

FWIW, if you had moved them to a hidden category, it would have been perhaps somewhat easier to bulk-revert-to-last-revision them all. But when neither of those things is possible for you at all, I think that’s a distinction without a difference.

Lastly, I’ll apologize for once again, treating a feature request as support . I think I do it because I have no power to make features, but I can solve problems.

4 Likes

Not a problem at all Jay, really appreciate it. Of course I would prefer if a GUI method could be implemented in Discourse, but if not I really appreciate you walking me through that.

1 Like

It’s certainly an edge case, but we try to keep track when a feature is asked multiple times (especially from customers) to have a better idea of when to move forward :slight_smile:

1 Like