Zulip server and web application. Open-source team chat that helps teams stay productive and focused.
do_make_stream_web_public: Send update to client.
Aman Agrawal233d250eff40
diff --git a/zerver/lib/actions.py b/zerver/lib/actions.pyindex 4b53b6a6eb5..7bf72418b7f 100644--- a/zerver/lib/actions.py+++ b/zerver/lib/actions.py@@ -4822,6 +4822,21 @@ def do_make_stream_web_public(stream: Stream) -> None:stream.history_public_to_subscribers = Truestream.save(update_fields=["invite_only", "history_public_to_subscribers", "is_web_public"])+ # We reuse "invite_only" stream update API route here because+ # both are similar events and similar UI updates will be required+ # by the client to update this property for the user.+ event = dict(+ op="update",+ type="stream",+ property="invite_only",+ value=False,+ history_public_to_subscribers=True,+ is_web_public=True,+ stream_id=stream.id,+ name=stream.name,+ )+ send_event(stream.realm, event, can_access_stream_user_ids(stream))+def do_change_stream_permission(stream: Stream,diff --git a/zerver/lib/events.py b/zerver/lib/events.pyindex acaaff16c9e..53e82529aaa 100644--- a/zerver/lib/events.py+++ b/zerver/lib/events.py@@ -887,6 +887,12 @@ def apply_event(obj[event["property"]] = event["value"]if event["property"] == "description":obj["rendered_description"] = event["rendered_description"]+ if event.get("history_public_to_subscribers") is not None:+ obj["history_public_to_subscribers"] = event[+ "history_public_to_subscribers"+ ]+ if event.get("is_web_public") is not None:+ obj["is_web_public"] = event["is_web_public"]# Also update the pure streams dataif "streams" in state:for stream in state["streams"]:@@ -896,6 +902,13 @@ def apply_event(stream[prop] = event["value"]if prop == "description":stream["rendered_description"] = event["rendered_description"]+ if event.get("history_public_to_subscribers") is not None:+ stream["history_public_to_subscribers"] = event[+ "history_public_to_subscribers"+ ]+ if event.get("is_web_public") is not None:+ stream["is_web_public"] = event["is_web_public"]+elif event["type"] == "default_streams":state["realm_default_streams"] = event["default_streams"]elif event["type"] == "default_stream_groups":diff --git a/zerver/tests/test_events.py b/zerver/tests/test_events.pyindex 58c2934d4d6..ed4e9343199 100644--- a/zerver/tests/test_events.py+++ b/zerver/tests/test_events.py@@ -42,8 +42,8 @@ from zerver.lib.actions import (do_change_plan_type,do_change_realm_domain,do_change_stream_description,- do_change_stream_invite_only,do_change_stream_message_retention_days,+ do_change_stream_permission,do_change_stream_post_policy,do_change_subscription_property,do_change_user_delivery_email,@@ -2416,9 +2416,16 @@ class SubscribeActionTest(BaseAction):events = self.verify_action(action, include_subscribers=include_subscribers)check_stream_update("events[0]", events[0])- # Update stream privacy- action = lambda: do_change_stream_invite_only(- stream, True, history_public_to_subscribers=True+ # Update stream privacy - make stream web public+ action = lambda: do_change_stream_permission(+ stream, invite_only=False, history_public_to_subscribers=True, is_web_public=True+ )+ events = self.verify_action(action, include_subscribers=include_subscribers)+ check_stream_update("events[0]", events[0])++ # Update stream privacy - make stream private+ action = lambda: do_change_stream_permission(+ stream, invite_only=True, history_public_to_subscribers=True, is_web_public=False)events = self.verify_action(action, include_subscribers=include_subscribers)check_stream_update("events[0]", events[0])