mirror of https://github.com/zulip/zulip.git
settings: Refetch realm and user profile objects.
This is a temporary solution to make sure stale objects from cache are not used when previous request updated multiple settings.
This commit is contained in:
parent
5b1326668f
commit
a0efc0ee76
|
@ -177,7 +177,14 @@ def update_realm(
|
||||||
Json[int] | None, ApiParamConfig("can_access_all_users_group")
|
Json[int] | None, ApiParamConfig("can_access_all_users_group")
|
||||||
] = None,
|
] = None,
|
||||||
) -> HttpResponse:
|
) -> HttpResponse:
|
||||||
realm = user_profile.realm
|
# Realm object is being refetched here to make sure that we
|
||||||
|
# do not use stale object from cache which can happen when a
|
||||||
|
# previous request tried updating multiple settings in a single
|
||||||
|
# request.
|
||||||
|
#
|
||||||
|
# TODO: Change the cache flushing strategy to make sure cache
|
||||||
|
# does not contain stale objects.
|
||||||
|
realm = Realm.objects.get(id=user_profile.realm_id)
|
||||||
|
|
||||||
# Additional validation/error checking beyond types go here, so
|
# Additional validation/error checking beyond types go here, so
|
||||||
# the entire request can succeed or fail atomically.
|
# the entire request can succeed or fail atomically.
|
||||||
|
|
|
@ -305,6 +305,14 @@ def json_change_settings(
|
||||||
),
|
),
|
||||||
web_navigate_to_sent_message: bool | None = REQ(json_validator=check_bool, default=None),
|
web_navigate_to_sent_message: bool | None = REQ(json_validator=check_bool, default=None),
|
||||||
) -> HttpResponse:
|
) -> HttpResponse:
|
||||||
|
# UserProfile object is being refetched here to make sure that we
|
||||||
|
# do not use stale object from cache which can happen when a
|
||||||
|
# previous request tried updating multiple settings in a single
|
||||||
|
# request.
|
||||||
|
#
|
||||||
|
# TODO: Change the cache flushing strategy to make sure cache
|
||||||
|
# does not contain stale objects.
|
||||||
|
user_profile = UserProfile.objects.get(id=user_profile.id)
|
||||||
if (
|
if (
|
||||||
default_language is not None
|
default_language is not None
|
||||||
or notification_sound is not None
|
or notification_sound is not None
|
||||||
|
|
Loading…
Reference in New Issue