discourse/plugins/automation/lib
Gabriel Grubba 1fba925cfb
FEATURE: Add automation to remove uploads from deleted posts (#36020)
This PR introduces a new automation script that removes uploads attached
to deleted posts.

Using this automation will add a revision to deleted posts by the System
User, removing the upload or attachment references. This Automation goes
a 1000 by every run and does not re-run on already ran posts

When the automation cleans the posts, uploads will no longer have
reference to the post and on the next time the [clean up uploads
job](f413e1b0de/app/jobs/scheduled/clean_up_uploads.rb (L1-L79))
runs it will permanently removes the uploads.

Example of automation run:

```
 Hey it is a regular post with a link to [Discourse](https://www.discourse.org) 
 and an image: ![logo.png|100x200](upload://gj6GJHlc1Sa5YXuGz549oXBbcFv.png)
 and a file: [small.pdf|attachment](upload://3bWzVVoRhUXxi7tiPenInoebHyX.pdf) (130 Bytes)
```
When the automation has run in this post, this will be the revisioned
version:

```
 Hey it is a regular post with a link to [Discourse](https://www.discourse.org) 
 and an image:
 and a file: 
```

---------

Co-authored-by: Penar Musaraj <pmusaraj@gmail.com>
2025-11-18 14:21:03 -03:00
..
discourse_automation FEATURE: Add automation to remove uploads from deleted posts (#36020) 2025-11-18 14:21:03 -03:00
tasks