Completely deleting previous versions of a post or message

AI-generated summary

Users discuss the need to permanently delete sensitive attachments or URLs from posts or messages, especially in private or debug contexts, to prevent lingering exposure—even to admins. Meteor0id raises the issue, noting that current deletion only hides content, not erases it. IAmGav points to a recent GitHub commit that may enable true deletion. Meteor0id expresses enthusiasm, noting the commit’s recency and applicability to messages. Ivan_Rapekas clarifies that the merged feature doesn’t yet address deleting attachments from specific post versions on self-hosted instances. He provides a manual workaround using SQL and Rails console to locate and delete large attachments by SHA1, but notes the core question—how to delete attachments from post versions—remains unresolved.

Say you had to send someone an Android debug log. These logs contain a log of private information. You shouldn’t post that URL in public, and if you message it in person the URL or attachment should be deleted soon after.

Even admins or moderators shouldn’t be able to recover that URL or attachment.
If we can’t delete it it will forever remain visible to the sender, and to all admins and moderators. These logs accumulate over time and it’s a lot of sensitive information lingering forever.

How can we not just hide that URL or attachment but actually delete it?

with this PR, it seems possible. i like :slight_smile:

https://github.com/discourse/discourse/commit/c4843fc1c18fc9fb077d61e59615f54c4735bb42

Sounds like something we need indeed. And it should also apply to messages.
Wow this was committed 3 hours ago? Great!

Hi, it seems that feature merged is not the similar that title contains. With data explorer I found that some version of certain wiki topic had a big attachment which I’d like to destroy.

Just want to say how to delete an attachment from version the post on self-hosted instances. Unfortunately method from Search attachments by storage name cannot be applied in this case (unable to get sha1 from filename).

First find sha1 using SQL:

sudo /var/discourse/launcher enter app
su - discourse
psql
SELECT filesize, original_filename, sha1 FROM uploads WHERE filesize > 3000000 order BY filesize desc;

then you get sha1. Next, close the connection to db, exit from user to root and open rails command line:

ctrl+d
ctrl+d
rails c
pry(main)> Upload.find_by(sha1: '<sha1>')

Finally you get url of the attachment pointing to the filesystem location. The question of the topic is still opened.