diff --git a/zerver/lib/actions.py b/zerver/lib/actions.py index 6db8670bdd..59147baa4b 100644 --- a/zerver/lib/actions.py +++ b/zerver/lib/actions.py @@ -2300,6 +2300,7 @@ def notify_subscriptions_added(user_profile: UserProfile, stream_id=stream.id, in_home_view=subscription.in_home_view, invite_only=stream.invite_only, + is_announcement_only=stream.is_announcement_only, color=subscription.color, email_address=encode_email_address(stream), desktop_notifications=subscription.desktop_notifications, @@ -3939,6 +3940,7 @@ def get_web_public_subs(realm: Realm) -> SubHelperT: {'name': stream.name, 'in_home_view': True, 'invite_only': False, + 'is_announcement_only': stream.is_announcement_only, 'color': get_next_color(), 'desktop_notifications': True, 'audible_notifications': True, @@ -3980,7 +3982,7 @@ def gather_subscriptions_helper(user_profile: UserProfile, stream_ids.add(sub['stream_id']) all_streams = get_active_streams(user_profile.realm).select_related( - "realm").values("id", "name", "invite_only", "realm_id", + "realm").values("id", "name", "invite_only", "is_announcement_only", "realm_id", "email_token", "description", "date_created") stream_dicts = [stream for stream in all_streams if stream['id'] in stream_ids] @@ -4032,6 +4034,7 @@ def gather_subscriptions_helper(user_profile: UserProfile, stream_dict = {'name': stream["name"], 'in_home_view': sub["in_home_view"], 'invite_only': stream["invite_only"], + 'is_announcement_only': stream["is_announcement_only"], 'color': sub["color"], 'desktop_notifications': sub["desktop_notifications"], 'audible_notifications': sub["audible_notifications"], @@ -4064,6 +4067,7 @@ def gather_subscriptions_helper(user_profile: UserProfile, if is_public or user_profile.is_realm_admin: stream_dict = {'name': stream['name'], 'invite_only': stream['invite_only'], + 'is_announcement_only': stream['is_announcement_only'], 'stream_id': stream['id'], 'is_old_stream': is_old_stream(stream["date_created"]), 'stream_weekly_traffic': get_average_weekly_stream_traffic(stream["id"], diff --git a/zerver/lib/events.py b/zerver/lib/events.py index 1171d03154..fc21eb58ea 100644 --- a/zerver/lib/events.py +++ b/zerver/lib/events.py @@ -415,6 +415,7 @@ def apply_event(state: Dict[str, Any], stream_data['subscribers'] = [] stream_data['stream_weekly_traffic'] = 0 stream_data['is_old_stream'] = False + stream_data['is_announcement_only'] = False # Add stream to never_subscribed (if not invite_only) state['never_subscribed'].append(stream_data) state['streams'].append(stream) diff --git a/zerver/tests/test_events.py b/zerver/tests/test_events.py index b715eb6cc2..b2f27f258e 100644 --- a/zerver/tests/test_events.py +++ b/zerver/tests/test_events.py @@ -1926,6 +1926,7 @@ class EventsRegisterTest(ZulipTestCase): ('description', check_string), ('email_address', check_string), ('invite_only', check_bool), + ('is_announcement_only', check_bool), ('in_home_view', check_bool), ('name', check_string), ('desktop_notifications', check_bool),