mirror of
https://github.com/zulip/zulip.git
synced 2025-11-13 10:26:28 +00:00
register: Include archived channels in "streams" field.
This commit is contained in:
3
api_docs/unmerged.d/ZF-5769ba
Normal file
3
api_docs/unmerged.d/ZF-5769ba
Normal file
@@ -0,0 +1,3 @@
|
|||||||
|
* [`POST /register`](/api/register-queue): The `streams` data
|
||||||
|
structure now includes archived channels for clients that
|
||||||
|
declared the `archived_channels` client capability.
|
||||||
@@ -784,6 +784,7 @@ def fetch_initial_state_data(
|
|||||||
state["streams"] = do_get_streams(
|
state["streams"] = do_get_streams(
|
||||||
user_profile,
|
user_profile,
|
||||||
include_web_public=True,
|
include_web_public=True,
|
||||||
|
exclude_archived=not archived_channels,
|
||||||
include_all=True,
|
include_all=True,
|
||||||
anonymous_group_membership=anonymous_group_membership_data_dict,
|
anonymous_group_membership=anonymous_group_membership_data_dict,
|
||||||
)
|
)
|
||||||
@@ -1307,11 +1308,8 @@ def apply_event(
|
|||||||
|
|
||||||
if event["op"] == "delete":
|
if event["op"] == "delete":
|
||||||
deleted_stream_ids = {stream["stream_id"] for stream in event["streams"]}
|
deleted_stream_ids = {stream["stream_id"] for stream in event["streams"]}
|
||||||
if "streams" in state:
|
|
||||||
state["streams"] = [
|
|
||||||
s for s in state["streams"] if s["stream_id"] not in deleted_stream_ids
|
|
||||||
]
|
|
||||||
|
|
||||||
|
updated_first_message_ids: dict[int, int] = dict()
|
||||||
if archived_channels:
|
if archived_channels:
|
||||||
for stream in state["subscriptions"]:
|
for stream in state["subscriptions"]:
|
||||||
if stream["stream_id"] in deleted_stream_ids:
|
if stream["stream_id"] in deleted_stream_ids:
|
||||||
@@ -1321,17 +1319,32 @@ def apply_event(
|
|||||||
if stream["stream_id"] in deleted_stream_ids:
|
if stream["stream_id"] in deleted_stream_ids:
|
||||||
stream["is_archived"] = True
|
stream["is_archived"] = True
|
||||||
if stream["first_message_id"] is None:
|
if stream["first_message_id"] is None:
|
||||||
stream["first_message_id"] = Stream.objects.get(
|
new_first_message_id = Stream.objects.get(
|
||||||
id=stream["stream_id"]
|
id=stream["stream_id"]
|
||||||
).first_message_id
|
).first_message_id
|
||||||
|
assert new_first_message_id is not None
|
||||||
|
stream["first_message_id"] = new_first_message_id
|
||||||
|
updated_first_message_ids[stream["stream_id"]] = new_first_message_id
|
||||||
|
|
||||||
for stream in state["never_subscribed"]:
|
for stream in state["never_subscribed"]:
|
||||||
if stream["stream_id"] in deleted_stream_ids:
|
if stream["stream_id"] in deleted_stream_ids:
|
||||||
stream["is_archived"] = True
|
stream["is_archived"] = True
|
||||||
if stream["first_message_id"] is None:
|
if stream["first_message_id"] is None:
|
||||||
stream["first_message_id"] = Stream.objects.get(
|
new_first_message_id = Stream.objects.get(
|
||||||
id=stream["stream_id"]
|
id=stream["stream_id"]
|
||||||
).first_message_id
|
).first_message_id
|
||||||
|
assert new_first_message_id is not None
|
||||||
|
stream["first_message_id"] = new_first_message_id
|
||||||
|
updated_first_message_ids[stream["stream_id"]] = new_first_message_id
|
||||||
|
|
||||||
|
if "streams" in state:
|
||||||
|
for stream in state["streams"]:
|
||||||
|
if stream["stream_id"] in deleted_stream_ids:
|
||||||
|
stream["is_archived"] = True
|
||||||
|
if stream["stream_id"] in updated_first_message_ids:
|
||||||
|
stream["first_message_id"] = updated_first_message_ids[
|
||||||
|
stream["stream_id"]
|
||||||
|
]
|
||||||
else:
|
else:
|
||||||
state["subscriptions"] = [
|
state["subscriptions"] = [
|
||||||
stream
|
stream
|
||||||
@@ -1351,6 +1364,11 @@ def apply_event(
|
|||||||
if stream["stream_id"] not in deleted_stream_ids
|
if stream["stream_id"] not in deleted_stream_ids
|
||||||
]
|
]
|
||||||
|
|
||||||
|
if "streams" in state:
|
||||||
|
state["streams"] = [
|
||||||
|
s for s in state["streams"] if s["stream_id"] not in deleted_stream_ids
|
||||||
|
]
|
||||||
|
|
||||||
if event["op"] == "update":
|
if event["op"] == "update":
|
||||||
# For legacy reasons, we call stream data 'subscriptions' in
|
# For legacy reasons, we call stream data 'subscriptions' in
|
||||||
# the state var here, for the benefit of the JS code.
|
# the state var here, for the benefit of the JS code.
|
||||||
|
|||||||
@@ -15743,8 +15743,12 @@ paths:
|
|||||||
For organization administrators, this will include all private channels
|
For organization administrators, this will include all private channels
|
||||||
in the organization.
|
in the organization.
|
||||||
|
|
||||||
**Changes**: As of Zulip 8.0 (feature level 205), this will include all
|
**Changes**: Before Zulip 11.0 (feature level ZF-5769ba), archived channels
|
||||||
web-public channels in the organization as well.
|
did not appear in this list, even if the `archived_channels` [client
|
||||||
|
capability][client-capabilities] was declared by the client.
|
||||||
|
|
||||||
|
As of Zulip 8.0 (feature level 205), this will include all web-public
|
||||||
|
channels in the organization as well.
|
||||||
realm_default_streams:
|
realm_default_streams:
|
||||||
type: array
|
type: array
|
||||||
items:
|
items:
|
||||||
|
|||||||
Reference in New Issue
Block a user