Skip to content

Commit 693b367

Browse files
PIG208timabbott
authored andcommitted
muted users: Add support to muting bots.
We intentionally disallow muting bots previously upon a pending design decision in zulip#16915. This lifts that constraint. Fixes zulip#22693.
1 parent 2766445 commit 693b367

File tree

6 files changed

+17
-7
lines changed

6 files changed

+17
-7
lines changed

api_docs/changelog.md

+6
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,12 @@ format used by the Zulip server that they are interacting with.
2020

2121
## Changes in Zulip 8.0
2222

23+
**Feature level 188**
24+
25+
* [`POST /users/me/muted_users/{muted_user_id}`](/api/mute-user),
26+
[`DELETE /users/me/muted_users/{muted_user_id}`](/api/unmute-user):
27+
Added support to mute/unmute bot users.
28+
2329
Feature levels 186-187 are reserved for future use in 7.x maintenance
2430
releases.
2531

version.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@
3333
# Changes should be accompanied by documentation explaining what the
3434
# new level means in api_docs/changelog.md, as well as "**Changes**"
3535
# entries in the endpoint's documentation in `zulip.yaml`.
36-
API_FEATURE_LEVEL = 185
36+
API_FEATURE_LEVEL = 188
3737

3838
# Bump the minor PROVISION_VERSION to indicate that folks should provision
3939
# only when going from an old version of the code to a newer version. Bump

web/src/popovers.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -193,7 +193,7 @@ function show_user_info_popover_manage_menu(element, user) {
193193
const is_me = people.is_my_user_id(user.user_id);
194194
const is_muted = muted_users.is_user_muted(user.user_id);
195195
const is_system_bot = user.is_system_bot;
196-
const muting_allowed = !is_me && !user.is_bot;
196+
const muting_allowed = !is_me;
197197

198198
const args = {
199199
can_mute: muting_allowed && !is_muted,

zerver/openapi/zulip.yaml

+2
Original file line numberDiff line numberDiff line change
@@ -18776,6 +18776,8 @@ components:
1877618776
in: path
1877718777
description: |
1877818778
The ID of the user to mute/un-mute.
18779+
18780+
**Changes**: Before Zulip 8.0 (feature level 188), it was an error to specify a bot user.
1877918781
schema:
1878018782
type: integer
1878118783
example: 10

zerver/tests/test_muted_users.py

+5-3
Original file line numberDiff line numberDiff line change
@@ -59,9 +59,11 @@ def test_add_muted_user_mute_bot(self) -> None:
5959

6060
url = f"/api/v1/users/me/muted_users/{muted_id}"
6161
result = self.api_post(hamlet, url)
62-
# Currently we do not allow muting bots. This is the error message
63-
# from `access_user_by_id`.
64-
self.assert_json_error(result, "No such user")
62+
self.assert_json_success(result)
63+
64+
url = f"/api/v1/users/me/muted_users/{muted_id}"
65+
result = self.api_delete(hamlet, url)
66+
self.assert_json_success(result)
6567

6668
def test_add_muted_user_mute_twice(self) -> None:
6769
hamlet = self.example_user("hamlet")

zerver/views/muted_users.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ def mute_user(request: HttpRequest, user_profile: UserProfile, muted_user_id: in
1616
raise JsonableError(_("Cannot mute self"))
1717

1818
muted_user = access_user_by_id(
19-
user_profile, muted_user_id, allow_bots=False, allow_deactivated=True, for_admin=False
19+
user_profile, muted_user_id, allow_bots=True, allow_deactivated=True, for_admin=False
2020
)
2121
date_muted = timezone_now()
2222

@@ -32,7 +32,7 @@ def unmute_user(
3232
request: HttpRequest, user_profile: UserProfile, muted_user_id: int
3333
) -> HttpResponse:
3434
muted_user = access_user_by_id(
35-
user_profile, muted_user_id, allow_bots=False, allow_deactivated=True, for_admin=False
35+
user_profile, muted_user_id, allow_bots=True, allow_deactivated=True, for_admin=False
3636
)
3737
mute_object = get_mute_object(user_profile, muted_user)
3838

0 commit comments

Comments
 (0)