From 0b68f264c6d11417d3f69b722d77d344294b81c1 Mon Sep 17 00:00:00 2001 From: Dinesh Date: Sun, 3 Oct 2021 12:10:03 +0530 Subject: [PATCH] apply_event: Do not include new user settings in the top level. From 430c5cb, in `fetch_initial_state_data`, we only include legacy settings in the top level of `state` and the newer ones are stored in `state['user_settings']`. That should've had a corresponding change in apply_event(). Also, fixed a test related to this logic. --- zerver/lib/events.py | 6 +++++- zerver/tests/test_event_system.py | 7 ++++++- 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/zerver/lib/events.py b/zerver/lib/events.py index 745c78863d..70fc0f0407 100644 --- a/zerver/lib/events.py +++ b/zerver/lib/events.py @@ -1197,7 +1197,11 @@ def apply_event( # this setting is not a part of UserBaseSettings class. if event["property"] != "timezone": assert event["property"] in UserProfile.property_types - state[event["property"]] = event["value"] + if event["property"] in { + **UserProfile.display_settings_legacy, + **UserProfile.notification_settings_legacy, + }: + state[event["property"]] = event["value"] state["user_settings"][event["property"]] = event["value"] elif event["type"] == "invites_changed": pass diff --git a/zerver/tests/test_event_system.py b/zerver/tests/test_event_system.py index a8ac735e45..871aaa50dc 100644 --- a/zerver/tests/test_event_system.py +++ b/zerver/tests/test_event_system.py @@ -564,7 +564,12 @@ class FetchInitialStateDataTest(ZulipTestCase): ) self.assertIn("user_settings", result) for prop in UserProfile.property_types: - self.assertIn(prop, result) + if prop in { + **UserProfile.display_settings_legacy, + **UserProfile.notification_settings_legacy, + }: + # Only legacy settings are included in the top level. + self.assertIn(prop, result) self.assertIn(prop, result["user_settings"])