mute user: Remove unnecessary check for double muting.

In 141b0c4, we added code to handle races caused by duplicate muting
requests. That code can also handle the non-race condition, so we don't
require the first check.
This commit is contained in:
Abhijeet Prasad Bodas 2023-02-10 20:17:06 +05:30 committed by Tim Abbott
parent ca70089842
commit 9fde88796a
2 changed files with 0 additions and 11 deletions

View File

@ -76,14 +76,6 @@ class MutedUsersTests(ZulipTestCase):
result = self.api_post(hamlet, url) result = self.api_post(hamlet, url)
self.assert_json_error(result, "User already muted") self.assert_json_error(result, "User already muted")
# Verify the error handling for the database level
# IntegrityError we'll get with a race between two processes
# trying to mute the user. To do this, we patch the
# get_mute_object function to always return None.
with mock.patch("zerver.views.muted_users.get_mute_object", return_value=None):
result = self.api_post(hamlet, url)
self.assert_json_error(result, "User already muted")
def _test_add_muted_user_valid_data(self, deactivate_user: bool = False) -> None: def _test_add_muted_user_valid_data(self, deactivate_user: bool = False) -> None:
hamlet = self.example_user("hamlet") hamlet = self.example_user("hamlet")
self.login_user(hamlet) self.login_user(hamlet)

View File

@ -20,9 +20,6 @@ def mute_user(request: HttpRequest, user_profile: UserProfile, muted_user_id: in
) )
date_muted = timezone_now() date_muted = timezone_now()
if get_mute_object(user_profile, muted_user) is not None:
raise JsonableError(_("User already muted"))
try: try:
do_mute_user(user_profile, muted_user, date_muted) do_mute_user(user_profile, muted_user, date_muted)
except IntegrityError: except IntegrityError: