mirror of https://github.com/zulip/zulip.git
actions: Deduplicate parts of get_web_public_subs.
This has the side of effect of making new fields we add to Stream be automatically included, which will help maintain this code as we upgrade it. This commit adds is_web_public, history_public_to_subscribers, and email_notifications fields to the dictionary.
This commit is contained in:
parent
bbcfd03541
commit
238bc386cb
|
@ -4708,26 +4708,27 @@ def get_web_public_subs(realm: Realm) -> SubHelperT:
|
||||||
color_idx = (color_idx + 1) % len(STREAM_ASSIGNMENT_COLORS)
|
color_idx = (color_idx + 1) % len(STREAM_ASSIGNMENT_COLORS)
|
||||||
return color
|
return color
|
||||||
|
|
||||||
subscribed = [
|
subscribed = []
|
||||||
{'name': stream.name,
|
for stream in Stream.objects.filter(realm=realm, is_web_public=True, deactivated=False):
|
||||||
'is_muted': False,
|
stream_dict = stream.to_dict()
|
||||||
'invite_only': False,
|
|
||||||
'is_announcement_only': stream.is_announcement_only,
|
# Add versions of the Subscription fields based on a simulated
|
||||||
'color': get_next_color(),
|
# new user subscription set.
|
||||||
'desktop_notifications': True,
|
stream_dict['is_muted'] = False
|
||||||
'audible_notifications': True,
|
stream_dict['color'] = get_next_color()
|
||||||
'push_notifications': False,
|
stream_dict['desktop_notifications'] = True
|
||||||
'pin_to_top': False,
|
stream_dict['audible_notifications'] = True
|
||||||
'stream_id': stream.id,
|
stream_dict['push_notifications'] = True
|
||||||
'description': stream.description,
|
stream_dict['email_notifications'] = True
|
||||||
'rendered_description': stream.rendered_description,
|
stream_dict['pin_to_top'] = False
|
||||||
'is_old_stream': is_old_stream(stream.date_created),
|
stream_dict['is_old_stream'] = is_old_stream(stream.date_created)
|
||||||
'first_message_id': stream.first_message_id,
|
stream_weekly_traffic = get_average_weekly_stream_traffic(stream.id,
|
||||||
'stream_weekly_traffic': get_average_weekly_stream_traffic(stream.id,
|
stream.date_created,
|
||||||
stream.date_created,
|
{})
|
||||||
{}),
|
stream_dict['stream_weekly_traffic'] = stream_weekly_traffic
|
||||||
'email_address': ''}
|
stream_dict['email_address'] = ''
|
||||||
for stream in Stream.objects.filter(realm=realm, is_web_public=True, deactivated=False)]
|
subscribed.append(stream_dict)
|
||||||
|
|
||||||
return (subscribed, [], [])
|
return (subscribed, [], [])
|
||||||
|
|
||||||
# In general, it's better to avoid using .values() because it makes
|
# In general, it's better to avoid using .values() because it makes
|
||||||
|
|
Loading…
Reference in New Issue