Skip to content

armgit / zulip

Public Imported from GitHub
0

Zulip server and web application. Open-source team chat that helps teams stay productive and focused.

message_send: Split checks into separate condition for coverage.

The Dance96321753b848
diff --git a/zerver/actions/message_send.py b/zerver/actions/message_send.py
index 78159a90602..f2bf0f8ae9e 100644
--- a/zerver/actions/message_send.py
+++ b/zerver/actions/message_send.py
@@ -2224,7 +2224,10 @@ def send_user_profile_update_notification(
acting_user: UserProfile | None,
changes: list[UserProfileChangeDict],
) -> None:
- if not user_profile.is_active or user_profile.is_bot:
+ if not user_profile.is_active:
+ return
+
+ if user_profile.is_bot:
return
if acting_user is not None and acting_user.id == user_profile.id:
diff --git a/zerver/tests/test_users.py b/zerver/tests/test_users.py
index f0c701be3f4..bb8a64bff4c 100644
--- a/zerver/tests/test_users.py
+++ b/zerver/tests/test_users.py
@@ -2484,6 +2484,20 @@ class ActivateTest(ZulipTestCase):
],
)
+ def test_no_exception_for_profile_update_notification_to_deactivated_user(self) -> None:
+ hamlet = self.example_user("hamlet")
+ do_deactivate_user(hamlet, acting_user=None)
+ self.assertFalse(hamlet.is_active)
+
+ new_name = "spammer"
+ self.login("iago")
+ hamlet = self.example_user("hamlet")
+ req = dict(full_name=new_name)
+ result = self.client_patch(f"/json/users/{hamlet.id}", req)
+ self.assert_json_success(result)
+ hamlet = self.example_user("hamlet")
+ self.assertEqual(hamlet.full_name, new_name)
+
class DeactivateActionsTest(ZulipTestCase):
# Helper for setting up various types of messages.