user_groups: Use UserGroupMembersDict in initial state data.

On the event side, orjson does the work of converting
UserGroupMembersData to json. But when fetching intial state data,
UserGroupMembersData was being returned which is not
json-serializable. This was causing a mismatch in the `verify_action`
workflow of test_events related to stream group settings where
apply_events resulted in a state with `direct_members` and
`direct_subgroups` as part of an ordinary dict, while fetching initial
state data was giving us a UserGroupMembersData class.
This commit uses UserGroupMembersDict where appropriate. It will
still be good to keep around the dataclass class since it has the added
benefit of storing the relevant value when needed.
This commit is contained in:
Shubham Padia
2025-03-11 19:10:37 +00:00
committed by Tim Abbott
parent 37d91d9759
commit b3862c5008
12 changed files with 179 additions and 128 deletions

View File

@@ -51,6 +51,7 @@ from zerver.lib.streams import (
from zerver.lib.subscription_info import bulk_get_subscriber_peer_info, get_subscribers_query
from zerver.lib.types import APISubscriptionDict, UserGroupMembersData
from zerver.lib.user_groups import (
convert_to_user_group_members_dict,
get_group_setting_value_for_api,
get_group_setting_value_for_audit_log_data,
update_or_create_user_group_for_setting,
@@ -1679,7 +1680,7 @@ def do_change_stream_group_based_setting(
op="update",
type="stream",
property=setting_name,
value=new_setting_api_value,
value=convert_to_user_group_members_dict(new_setting_api_value),
stream_id=stream.id,
name=stream.name,
)