From 70c0abc2e59d9b221ab63bfb9bbf6110c58b7bbb Mon Sep 17 00:00:00 2001 From: Aman Agrawal Date: Tue, 10 Nov 2020 20:32:55 +0530 Subject: [PATCH] do_change_stream_invite_only: Ensure stream is not web public. When changing stream permissions to invite_only or public, ensure that stream doesn't have is_web_public set to True. --- templates/zerver/api/changelog.md | 5 +++++ version.py | 2 +- zerver/lib/actions.py | 4 +++- zerver/lib/event_schema.py | 3 ++- zerver/openapi/zulip.yaml | 9 +++++++++ 5 files changed, 20 insertions(+), 3 deletions(-) diff --git a/templates/zerver/api/changelog.md b/templates/zerver/api/changelog.md index b3484d5366..d641a7dcf5 100644 --- a/templates/zerver/api/changelog.md +++ b/templates/zerver/api/changelog.md @@ -13,6 +13,11 @@ below features are supported. **Feature level 70** +* [`GET /events`](/api/get-events): Added `is_web_public` field to + `stream` events changing `invite_only`. + +**Feature level 70** + * [`POST /register`](/api/register-queue): Added new top-level `server_timestamp` field when fetching presence data, to match the existing presence API. diff --git a/version.py b/version.py index 5a37ee2dc5..e61d764479 100644 --- a/version.py +++ b/version.py @@ -32,7 +32,7 @@ DESKTOP_WARNING_VERSION = "5.4.3" # # Changes should be accompanied by documentation explaining what the # new level means in templates/zerver/api/changelog.md. -API_FEATURE_LEVEL = 70 +API_FEATURE_LEVEL = 71 # Bump the minor PROVISION_VERSION to indicate that folks should provision # only when going from an old version of the code to a newer version. Bump diff --git a/zerver/lib/actions.py b/zerver/lib/actions.py index b63aaae90e..3bb5892f83 100644 --- a/zerver/lib/actions.py +++ b/zerver/lib/actions.py @@ -4554,13 +4554,15 @@ def do_change_stream_invite_only( ) stream.invite_only = invite_only stream.history_public_to_subscribers = history_public_to_subscribers - stream.save(update_fields=["invite_only", "history_public_to_subscribers"]) + stream.is_web_public = False + stream.save(update_fields=["invite_only", "history_public_to_subscribers", "is_web_public"]) event = dict( op="update", type="stream", property="invite_only", value=invite_only, history_public_to_subscribers=history_public_to_subscribers, + is_web_public=False, stream_id=stream.id, name=stream.name, ) diff --git a/zerver/lib/event_schema.py b/zerver/lib/event_schema.py index 3a29dcc1fd..8b6f2afd57 100644 --- a/zerver/lib/event_schema.py +++ b/zerver/lib/event_schema.py @@ -1183,6 +1183,7 @@ stream_update_event = event_dict_type( optional_keys=[ ("rendered_description", str), ("history_public_to_subscribers", bool), + ("is_web_public", bool), ], ) _check_stream_update = make_checker(stream_update_event) @@ -1213,7 +1214,7 @@ def check_stream_update( assert extra_keys == set() assert isinstance(value, str) elif prop == "invite_only": - assert extra_keys == {"history_public_to_subscribers"} + assert extra_keys == {"history_public_to_subscribers", "is_web_public"} assert isinstance(value, bool) elif prop == "message_retention_days": assert extra_keys == set() diff --git a/zerver/openapi/zulip.yaml b/zerver/openapi/zulip.yaml index 5030254325..9951998a31 100644 --- a/zerver/openapi/zulip.yaml +++ b/zerver/openapi/zulip.yaml @@ -1085,6 +1085,14 @@ paths: Currently always true for public streams (i.e. invite_only=False implies history_public_to_subscribers=True), but clients should not make that assumption, as we may change that behavior in the future. + is_web_public: + type: boolean + description: | + Note: Only present if the changed property was `invite_only`. + + Whether the stream's history is now readable by web-public visitors. + + **Changes**: New in Zulip 5.0 (feature level 71). additionalProperties: false example: { @@ -1093,6 +1101,7 @@ paths: "property": "invite_only", "value": true, "history_public_to_subscribers": true, + "is_web_public": false, "stream_id": 11, "name": "test_stream", "id": 0,