streams: Fix incorrect setting value in stream creation event.

Value for "can_administer_channel_group" passed in stream
creation event was incorrect when there was no value passed
for the setting while creating the stream and thus the setting
was set to anonymous group containing stream creator as default.

This was because code for creating setting_groups_dict, which
is used to send setting values in the stream creation event,
incorrectly assumed that defaults for all settings is a system
group.

This was not noticed before because we pass all the settings
when creating streams using webapp, but can be reproduced
by creating streams using API without passing any value for
"can_administer_channel_group".
This commit is contained in:
Sahil Batra 2025-02-03 19:20:11 +05:30 committed by Tim Abbott
parent be8093197e
commit fd70e83980

View File

@ -617,9 +617,16 @@ def add_subscriptions_backend(
group_settings_map[setting_name] = get_stream_permission_default_group(
setting_name, system_groups_name_dict, creator=user_profile
)
setting_groups_dict[group_settings_map[setting_name].id] = group_settings_map[
setting_name
].id
if permission_configuration.default_group_name == "stream_creator_or_nobody":
# Default for some settings like "can_administer_channel_group"
# is anonymous group with stream creator.
setting_groups_dict[group_settings_map[setting_name].id] = (
AnonymousSettingGroupDict(direct_subgroups=[], direct_members=[user_profile.id])
)
else:
setting_groups_dict[group_settings_map[setting_name].id] = group_settings_map[
setting_name
].id
for stream_obj in streams_raw:
# 'color' field is optional