The discussion centers on automating the deletion of old, closed topics within a Discourse category. Tealk initially asks for a plugin to automatically delete topics after a set period following closure, noting that existing solutions like the unreplied topics plugin do not fit their needs. Heliosurge suggests using the built-in Topic Timer feature found in the topic wrench, which allows for auto-closing and auto-deletion. Tealk expresses concern that this requires manual configuration for each of the 7,000+ topics in their category.
Heliosurge further suggests exploring or sponsoring an Automation script to handle this at scale. Moin points to a related feature request on Meta regarding category-level auto-delete features. The conversation takes a technical turn when Dan_Eastwood reports a potential bug where topics created via splitting were automatically deleted despite not having an explicit timer set, questioning if this is a system error. Heliosurge clarifies that the timer is accessed via the wrench icon and confirms its presence in category settings.
To address the immediate need, Tealk shares a custom script they wrote to delete posts via the API. Moin critiques the script, noting it deletes topics based on creation date rather than closure date, which could lead to premature deletion of topics that were closed long after they were created. Tealk acknowledges this limitation, explaining that the API currently lacks a way to retrieve the date a post was closed, so they are using creation date as a proxy while working on additional parameters.
I am looking for a way to clean up a category. There are searches posted that are only valid for a certain period of time. Currently I close it after 2 months after the last answer.
Is there an automatic way to delete them after x days after closing?
I have found the following plugin, but it should not only delete topics that have not been replied to.
You might be able to have an Automation script. If a script does not currently exist. If you have the skills you can create an automation script. Or consider sponsoring one in Marketplace.
I just found two topic in the Deleted Topics logs which were “Deleted by Automatic Timer” and should not have been deleted. Both of these topics were created by me, splitting comments from a existing topics to a create the new topic which were auto-deleted ~12(?) days later. My best guess is the Delete Topic Timer was inadvertently set when I created these posts.
There is no Delete Topic Timer available to me in the moderator tools. I don’t see any Auto Delete Topic option as shown by @Heliosurge’s screencap above. The only timer I can control is to Close Comments.
So I think I understand why this happened, but I don’t know how to avoid it the next time. Is this a bug that can be fixed, or am I missing something?
If you click on the wrench for your topic you will see Topic Timer. Click on that. There is a dropdown menu to choose things like auto close, auto delete and more.
There is a topic timer option in Category settings but only see it for auto close.
Is that what the script you shared is doing? To me it seems it would delete closed topics that were created x days ago. So a topic which is closed quite a while after it was created because there were new replies in a longer timespan might get deleted almost immediately.
That is correct, I am currently still working on building in a few more parameters. I have very many old posts, which is why I’ve cleaned things up with this method for now.
Unfortunately, I cannot find any way via the API to find out the date when the post was closed.
The current workaround would be to use last_post and date it accordingly.