muted users: Add support to muting bots.

We intentionally disallow muting bots previously upon
a pending design decision in #16915.
This lifts that constraint.

Fixes #22693.
This commit is contained in:
Zixuan James Li 2023-06-13 12:15:36 -04:00 committed by Tim Abbott
parent 27664459cb
commit 693b3679e3
6 changed files with 17 additions and 7 deletions

View File

@ -20,6 +20,12 @@ format used by the Zulip server that they are interacting with.
## Changes in Zulip 8.0 ## Changes in Zulip 8.0
**Feature level 188**
* [`POST /users/me/muted_users/{muted_user_id}`](/api/mute-user),
[`DELETE /users/me/muted_users/{muted_user_id}`](/api/unmute-user):
Added support to mute/unmute bot users.
Feature levels 186-187 are reserved for future use in 7.x maintenance Feature levels 186-187 are reserved for future use in 7.x maintenance
releases. releases.

View File

@ -33,7 +33,7 @@ DESKTOP_WARNING_VERSION = "5.9.3"
# Changes should be accompanied by documentation explaining what the # Changes should be accompanied by documentation explaining what the
# new level means in api_docs/changelog.md, as well as "**Changes**" # new level means in api_docs/changelog.md, as well as "**Changes**"
# entries in the endpoint's documentation in `zulip.yaml`. # entries in the endpoint's documentation in `zulip.yaml`.
API_FEATURE_LEVEL = 185 API_FEATURE_LEVEL = 188
# Bump the minor PROVISION_VERSION to indicate that folks should provision # Bump the minor PROVISION_VERSION to indicate that folks should provision
# only when going from an old version of the code to a newer version. Bump # only when going from an old version of the code to a newer version. Bump

View File

@ -193,7 +193,7 @@ function show_user_info_popover_manage_menu(element, user) {
const is_me = people.is_my_user_id(user.user_id); const is_me = people.is_my_user_id(user.user_id);
const is_muted = muted_users.is_user_muted(user.user_id); const is_muted = muted_users.is_user_muted(user.user_id);
const is_system_bot = user.is_system_bot; const is_system_bot = user.is_system_bot;
const muting_allowed = !is_me && !user.is_bot; const muting_allowed = !is_me;
const args = { const args = {
can_mute: muting_allowed && !is_muted, can_mute: muting_allowed && !is_muted,

View File

@ -18776,6 +18776,8 @@ components:
in: path in: path
description: | description: |
The ID of the user to mute/un-mute. The ID of the user to mute/un-mute.
**Changes**: Before Zulip 8.0 (feature level 188), it was an error to specify a bot user.
schema: schema:
type: integer type: integer
example: 10 example: 10

View File

@ -59,9 +59,11 @@ class MutedUsersTests(ZulipTestCase):
url = f"/api/v1/users/me/muted_users/{muted_id}" url = f"/api/v1/users/me/muted_users/{muted_id}"
result = self.api_post(hamlet, url) result = self.api_post(hamlet, url)
# Currently we do not allow muting bots. This is the error message self.assert_json_success(result)
# from `access_user_by_id`.
self.assert_json_error(result, "No such user") url = f"/api/v1/users/me/muted_users/{muted_id}"
result = self.api_delete(hamlet, url)
self.assert_json_success(result)
def test_add_muted_user_mute_twice(self) -> None: def test_add_muted_user_mute_twice(self) -> None:
hamlet = self.example_user("hamlet") hamlet = self.example_user("hamlet")

View File

@ -16,7 +16,7 @@ def mute_user(request: HttpRequest, user_profile: UserProfile, muted_user_id: in
raise JsonableError(_("Cannot mute self")) raise JsonableError(_("Cannot mute self"))
muted_user = access_user_by_id( muted_user = access_user_by_id(
user_profile, muted_user_id, allow_bots=False, allow_deactivated=True, for_admin=False user_profile, muted_user_id, allow_bots=True, allow_deactivated=True, for_admin=False
) )
date_muted = timezone_now() date_muted = timezone_now()
@ -32,7 +32,7 @@ def unmute_user(
request: HttpRequest, user_profile: UserProfile, muted_user_id: int request: HttpRequest, user_profile: UserProfile, muted_user_id: int
) -> HttpResponse: ) -> HttpResponse:
muted_user = access_user_by_id( muted_user = access_user_by_id(
user_profile, muted_user_id, allow_bots=False, allow_deactivated=True, for_admin=False user_profile, muted_user_id, allow_bots=True, allow_deactivated=True, for_admin=False
) )
mute_object = get_mute_object(user_profile, muted_user) mute_object = get_mute_object(user_profile, muted_user)