撤销官方警告

:bookmark: This guide explains how to remove an official warning in Discourse via the console, particularly aimed at self-hosting users.

:person_raising_hand: Required user level: System Administrator
:desktop_computer: Console access required

In certain situations, a warning issued to a user may need to be retracted. This action involves removing the warning through the console, which is accessible for those with server access. If you are a hosted customer, please contact the Discourse team (team@discourse.org) for assistance with this process.

Understanding user warnings

Official warnings are stored in the user_warnings table within the Discourse database. If you need to undo a warning, it means deleting the corresponding entry from this table.

Removing an official warning

To remove a warning, follow these steps:

  1. Access the server console:

    • Use SSH to connect to your Discourse server.
    • Enter the console with the following commands:
      cd /var/discourse/
      ./launcher enter app
      rails console
      
  2. Remove the latest warning:
    If the warning you want to delete is the most recent one, execute:

    UserWarning.last.destroy
    
  3. Find and remove a specific warning:
    If the warning wasn’t the last one, search for the specific warning using the user_id:

    UserWarning.where(user_id: the_user_id)
    

    This will return an array of warnings related to the user. Once you find the correct id, remove it using:

    UserWarning.find(3).destroy
    

Destroying the warning will not remove the private message (PM) sent; the PM will merely cease being marked as a warning.

Last edited by @SaraDev 2024-11-13T00:51:26Z

Check documentPerform check on document:
20 个赞

Is there any chance you could share the steps that I’d need to take to log in to the Console? I’ve tried Googling this but every guide seems to assume that the user will know how to do that.

Assuming you followed the standard installation guide, you would SSH into the server and run:

cd /var/discourse/
./launcher enter app
rails console
3 个赞

@JammyDodger。也许需要一个魔法链接将“console”和/或“rails”(或者“rails console”)链接到

2 个赞

嗯。这倒是个主意。:thinking: 不过我以前在这上面吃过亏。:slight_smile:

你说完之后,我会留意一下,看看它出现的频率。:+1:


我们目前正在查看文档,所以也许在这种情况下,在指南中添加完整的说明会比较好。

3 个赞

或者也许该部分将是“您可以在 Rails 中做的事情”,而“关于”或任何其他内容就足够了。

难道不应该更容易将这些作为处罚来处理,并有一个所有官方警告的日志,供管理员和版主随时管理吗?当版主不小心警告了一个名字相似的用户,然后不得不联系网站维护人员来解决问题时,这会非常困难。

1 个赞

我认为这里有一个#feature request:

2 个赞

是否可以通过 API 来完成此操作,而不仅仅是通过 Rails 控制台?