If I want to completely delete a post, I should just hide them?

My apologies, as I know this might have been discussed at length previously, but I am still trying to understand. On a reply by @codinghorror, a while back, he wrote:

https://meta.discourse.org/t/deleted-topics-where-are-they/22312/8

Will that mean that, if I want to completely delete a post, I should just hide them? Will the delete removed posts after setting apply to the forum administrator, and thus, the topics/posts deleted/hidden by the administrator’s account be removed after the n hours set? Are posts and topics considered the same, for this setting?

How can one delete uploads, so that the purge deleted uploads grace period days settings become applicable (Grace period (in days) before a deleted upload is erased)?

So, based on the silent acceptance this topic got, am I to assume hidden posts do not get deleted after 30 days, and thus the delete removed posts after setting is a placebo?

Okay, I must have missed this topic earlier, but here is my understanding of how that setting works.

  1. A Hidden post is still a post that can be seen by other users, it has the message of “this content is hidden due to community flagging”, or something like that, and therefore it is still “visible”
  2. At 30 days (or whatever you have set), the post will be marked as “deleted”

This does not permanently destroy the post, instead it hides it from regular users to where only staff can see it. Discourse, to my knowledge, NEVER destroys a post entirely.

Uploads in that now deleted post, should eventually be cleaned up via the grace period at the next time it runs via Sidekiq.

3 个赞

Not trying to be nitpicky, but if delete doesn’t delete, then maybe that word shouldn’t be used. Flagged should replace the current Hidden, and Hidden should be made the new deleted.

I searched meta a lot, and found three years old developer discussions about implementing a real purge. There has been no advances on that idea, correct?

I am unaware of any plans for a real purge. The only way I know to do that is via the Rails console and calling post.destroy() on the post in question. So it technically exists, but isn’t automated in any form.

2 个赞

I tried the Rails console approach (found an old post referring to it), and it vomited errors at me, so I decided to hold that off.

The reply I referred about:

https://meta.discourse.org/t/tools-to-permanently-remove-or-delete-spam/5289/10?u=david_collantes

FYI, in Discourse, we “soft-delete” topics/posts. Meaning the content is still stored in the database but it flagged as being deleted and is thus not shown to standard users (admins can always seem them if they want to).

This help tremendously in dealing with spammers and/or misbehaving users.

@David_Collantes would you mind explaining why you wanted to completely erase the content of a post?

Imagine a user posts something really sensitive like someone’s credit card information, someone’s social security number, something that we really don’t want visible at all to anyone, or even something that the Legal team in your organization asks you to remove because may become a liability.

An additional factor is that “soft-deleted” posts seem to be accessible not only to administrators, but also to moderators. If you have a forum where community members may obtain a moderator role, this just complicates the scenarios around privacy.

If there is a command-line instruction to delete such posts in exceptional circumstances, that would work too.

2 个赞

Yes there are …

./launcher enter app
rails c
Post.find(THE_POST_ID).destroy

Note this is 100% non recoverable short of grabbing a backup, so be careful.

10 个赞

您好,
由于 Discourse 对帖子执行“软删除”,我们是否可以将此 Rails 命令视为彻底删除包含高度敏感信息(如 @icaria36 提供的示例)的帖子的推荐方式?如果不是,处理此类帖子的推荐方式是什么?

您是否想到过彻底删除此类帖子会导致 Discourse 中某些功能失效的情况?

2 个赞

使用 .destroy 硬删除帖子是推荐的做法。这不会破坏 Discourse 的任何功能,因为有后台任务会确保数据的一致性。

不过,在某些情况下,1 到 7 天内的统计计数可能会出现不一致。(例如,Sam 实际上只发布了 9996 条帖子,但系统显示为 9997 条。)

3 个赞

我不确定这是否是最理想的方案,但我使用了这段代码,将已删除话题中的用户帖子内容替换为 "[deleted]"。这样既保留了帖子的存在记录,而且看起来比彻底删除它们更安全。

# 先进行备份
deleted_topic_id = 1234
user_id = 5678

t = Topic.unscoped.find(deleted_topic_id)
ps = t.posts.select { |p| p.user_id == user_id }

# 使用 `ps.count` 进行检查

ps.each do |p|
  p.raw = '[deleted]'
  p.save
end

我没想到隐藏被标记的帖子并不会使其对其他论坛用户不可见。有没有办法缩短30天的删除时限?

1 个赞