Skip to content

Commit

Permalink
add anonymize endpoint
Browse files Browse the repository at this point in the history
  • Loading branch information
weber-s committed Feb 19, 2024
1 parent 5015e2d commit 2935cc2
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 0 deletions.
11 changes: 11 additions & 0 deletions src/pydiscourse/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -230,6 +230,17 @@ def trust_level(self, userid, level):
"""
return self._put(f"/admin/users/{userid}/trust_level", level=level)

def anonymize(self, userid):
"""
Args:
userid: the Discourse user ID
Returns:
"""
return self._put(f"/admin/users/{userid}/anonymize")

def suspend(self, userid, duration, reason):
"""
Suspend a user's account
Expand Down
6 changes: 6 additions & 0 deletions tests/test_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,12 @@ def test_by_external_id(self, discourse_client, discourse_request):

assert request.called_once

def test_anonymize(self, discourse_client, discourse_request):
request = discourse_request("put", "/admin/users/123/anonymize")
discourse_client.anonymize(123)

assert request.called_once

@pytest.mark.usefixtures("_frozen_time")
def test_suspend_user(self, discourse_client, discourse_request):
request = discourse_request("put", "/admin/users/123/suspend")
Expand Down

0 comments on commit 2935cc2

Please sign in to comment.