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.
This commit is contained in:
Aman Agrawal 2020-11-10 20:32:55 +05:30 committed by Tim Abbott
parent af2b1ef3a1
commit 70c0abc2e5
5 changed files with 20 additions and 3 deletions

View File

@ -13,6 +13,11 @@ below features are supported.
**Feature level 70** **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 * [`POST /register`](/api/register-queue): Added new top-level
`server_timestamp` field when fetching presence data, to match the `server_timestamp` field when fetching presence data, to match the
existing presence API. existing presence API.

View File

@ -32,7 +32,7 @@ DESKTOP_WARNING_VERSION = "5.4.3"
# #
# Changes should be accompanied by documentation explaining what the # Changes should be accompanied by documentation explaining what the
# new level means in templates/zerver/api/changelog.md. # 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 # 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 # only when going from an old version of the code to a newer version. Bump

View File

@ -4554,13 +4554,15 @@ def do_change_stream_invite_only(
) )
stream.invite_only = invite_only stream.invite_only = invite_only
stream.history_public_to_subscribers = history_public_to_subscribers 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( event = dict(
op="update", op="update",
type="stream", type="stream",
property="invite_only", property="invite_only",
value=invite_only, value=invite_only,
history_public_to_subscribers=history_public_to_subscribers, history_public_to_subscribers=history_public_to_subscribers,
is_web_public=False,
stream_id=stream.id, stream_id=stream.id,
name=stream.name, name=stream.name,
) )

View File

@ -1183,6 +1183,7 @@ stream_update_event = event_dict_type(
optional_keys=[ optional_keys=[
("rendered_description", str), ("rendered_description", str),
("history_public_to_subscribers", bool), ("history_public_to_subscribers", bool),
("is_web_public", bool),
], ],
) )
_check_stream_update = make_checker(stream_update_event) _check_stream_update = make_checker(stream_update_event)
@ -1213,7 +1214,7 @@ def check_stream_update(
assert extra_keys == set() assert extra_keys == set()
assert isinstance(value, str) assert isinstance(value, str)
elif prop == "invite_only": 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) assert isinstance(value, bool)
elif prop == "message_retention_days": elif prop == "message_retention_days":
assert extra_keys == set() assert extra_keys == set()

View File

@ -1085,6 +1085,14 @@ paths:
Currently always true for public streams (i.e. invite_only=False implies Currently always true for public streams (i.e. invite_only=False implies
history_public_to_subscribers=True), but clients should not make that history_public_to_subscribers=True), but clients should not make that
assumption, as we may change that behavior in the future. 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 additionalProperties: false
example: example:
{ {
@ -1093,6 +1101,7 @@ paths:
"property": "invite_only", "property": "invite_only",
"value": true, "value": true,
"history_public_to_subscribers": true, "history_public_to_subscribers": true,
"is_web_public": false,
"stream_id": 11, "stream_id": 11,
"name": "test_stream", "name": "test_stream",
"id": 0, "id": 0,