Undo an Official Warning

: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 involve two pieces of data in the Discourse database:

  1. A record in the user_warnings table linking the warning to a user and topic.
  2. The associated private message topic has its subtype set to "moderator_warning".

To fully undo a warning, both need to be addressed: the user_warnings record must be deleted, and the topic’s subtype must be reset.

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:

    warning = UserWarning.last
    warning.topic.update(subtype: TopicSubtype.user_to_user)
    warning.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:

    warning = UserWarning.find(3)
    warning.topic.update(subtype: TopicSubtype.user_to_user)
    warning.destroy
    

Destroying the warning record and resetting the topic subtype will remove the warning from the user’s warning count and unmark the PM as an official warning. The private message itself will not be deleted.

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개의 좋아요

아니면 해당 섹션을 "레일스에서 할 수 있는 것들"로 하고, About 섹션이나 기타 유사한 섹션만 충분히 제공하면 될 수도 있습니다.

이러한 문제를 페널티로 처리하고, 관리자와 모더레이터가 언제든지 관리할 수 있도록 모든 공식 경고 내역을 로그로 남겨두는 것이 훨씬 간단하지 않을까요? 모더레이터가 비슷한 이름의 사용자를 실수로 경고한 경우, 문제를 해결하기 위해 사이트 관리자에게 직접 연락해야 하는 상황이 발생하면 매우 곤란합니다.

1개의 좋아요

여기에 Contribute > Feature 요청이 있는 것 같습니다:

2개의 좋아요

Rails 콘솔이 아닌 API를 통해서도 이 작업을 수행할 수 있는 방법이 있을까요?