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.
This commit is contained in:
Dinesh 2021-10-03 12:10:03 +05:30 committed by Tim Abbott
parent 47da353366
commit 0b68f264c6
2 changed files with 11 additions and 2 deletions

View File

@ -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

View File

@ -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"])