muting: Handle the case of a race muting the same user twice.

This commit is contained in:
Alex Vandiver
2022-03-24 16:45:35 -07:00
committed by Tim Abbott
parent 781107308d
commit 141b0c4cec
2 changed files with 13 additions and 1 deletions

View File

@@ -106,7 +106,11 @@ def mute_user(request: HttpRequest, user_profile: UserProfile, muted_user_id: in
if get_mute_object(user_profile, muted_user) is not None:
raise JsonableError(_("User already muted"))
do_mute_user(user_profile, muted_user, date_muted)
try:
do_mute_user(user_profile, muted_user, date_muted)
except IntegrityError:
raise JsonableError(_("User already muted"))
return json_success(request)