Repository: zulip/zulip

Issue:
Mute Option Missing for Bots
When clicking the name of a user I get the "Mute this user" option, but there is no option to do so when clicking a bot's name.


Discussion:
Thanks for the report! Currently, muting bot users is not supported. We might implement this in the future.

Linking to this comment for backlogging purposes https://github.com/zulip/zulip/pull/16915#issuecomment-808875744.
Hello @zulip/server-bots, @zulip/server-settings members, this issue was labeled with the "area: settings (user)", "area: bots" labels, so you may want to check it out!

<!-- areaLabelAddition -->

@Virakal can you talk about why you wanted to mute a bot user? Some context would be helpful in thinking about this feature request. There's no significant technical impediment to adding support for muting bots.
@timabbott we have some bots that we'd like to use because they give quite useful information but not useful enough to warrant spamming everyone with a notification, like git commit bots and things. I've also had issues in the past where people have added bots to Slack servers that some people like but other people are just annoyed by, like the beer time bot.

I suppose ideally there would be individual notification settings for bots, like a notification badge would be nice for Git commits but I don't need them making sounds or being sent to my phone. I figure muting bots would be much simpler though.
@abhijeetbodas2001 do you remember why we didn't allow muting bot users when we first implemented the feature?
I don't remember anything in particular apart from because we had decided on the feature set keeping in mind the "(human) user you'd rather not interact with". Allowing muting bots should not be too difficult technically, in case we want the same feature set for bots as well.
Adding a "Mute bot" option sounds reasonable to me!
@zulipbot claim
Hello @amylcheng!

Thanks for your interest in Zulip! You have attempted to claim an issue without the label "help wanted". You can only claim and submit pull requests for issues with the [help wanted](https://github.com/zulip/zulip/issues?q=is%3Aopen+is%3Aissue+no%3Aassignee+label%3A%22help+wanted%22) label.

If this is your first time here, we recommend reading our [guide for new contributors](https://zulip.readthedocs.io/en/latest/overview/contributing.html) before getting started.

I am just doing a quick bump on this issue, since I recently discovered this bug in the context of deploying some of my own bots.

The comments indicate that a) this should be fairly easy and b) @alya signed off on the feature.
Yeah, let me tag this as a priority.

Resolving patch:
diff --git a/version.py b/version.py
--- a/version.py
+++ b/version.py
@@ -33,7 +33,7 @@
 # Changes should be accompanied by documentation explaining what the
 # new level means in api_docs/changelog.md, as well as "**Changes**"
 # 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
 # only when going from an old version of the code to a newer version. Bump
diff --git a/zerver/views/muted_users.py b/zerver/views/muted_users.py
--- a/zerver/views/muted_users.py
+++ b/zerver/views/muted_users.py
@@ -16,7 +16,7 @@ def mute_user(request: HttpRequest, user_profile: UserProfile, muted_user_id: in
         raise JsonableError(_("Cannot mute self"))
 
     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()
 
@@ -32,7 +32,7 @@ def unmute_user(
     request: HttpRequest, user_profile: UserProfile, muted_user_id: int
 ) -> HttpResponse:
     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)
 


Test patch:
diff --git a/zerver/tests/test_muted_users.py b/zerver/tests/test_muted_users.py
--- a/zerver/tests/test_muted_users.py
+++ b/zerver/tests/test_muted_users.py
@@ -59,9 +59,11 @@ def test_add_muted_user_mute_bot(self) -> None:
 
         url = f"/api/v1/users/me/muted_users/{muted_id}"
         result = self.api_post(hamlet, url)
-        # Currently we do not allow muting bots. This is the error message
-        # from `access_user_by_id`.
-        self.assert_json_error(result, "No such user")
+        self.assert_json_success(result)
+
+        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:
         hamlet = self.example_user("hamlet")