mirror of https://github.com/zulip/zulip.git
refactor: Clean up is_web_public flag.
The is_web_public flag is already in Stream.API_FIELDS, so there is no reason for all this complicated logic. There's no reason to hack it on to the subscription object.
This commit is contained in:
parent
4dce34ab8b
commit
ffee129a35
|
@ -4938,7 +4938,7 @@ def build_stream_dict_for_sub(
|
||||||
|
|
||||||
# Guest users lose access to subscribers when they are unsubscribed if the stream
|
# Guest users lose access to subscribers when they are unsubscribed if the stream
|
||||||
# is not web-public.
|
# is not web-public.
|
||||||
if not sub["active"] and user.is_guest and not sub["is_web_public"]:
|
if not sub["active"] and user.is_guest and not stream["is_web_public"]:
|
||||||
subscribers = None
|
subscribers = None
|
||||||
if subscribers is not None:
|
if subscribers is not None:
|
||||||
result["subscribers"] = subscribers
|
result["subscribers"] = subscribers
|
||||||
|
@ -4982,7 +4982,6 @@ def gather_subscriptions_helper(user_profile: UserProfile,
|
||||||
*Stream.API_FIELDS,
|
*Stream.API_FIELDS,
|
||||||
# The realm_id and recipient_id are generally not needed in the API.
|
# The realm_id and recipient_id are generally not needed in the API.
|
||||||
"realm_id",
|
"realm_id",
|
||||||
"is_web_public",
|
|
||||||
"recipient_id",
|
"recipient_id",
|
||||||
# email_token isn't public to some users with access to
|
# email_token isn't public to some users with access to
|
||||||
# the stream, so doesn't belong in API_FIELDS.
|
# the stream, so doesn't belong in API_FIELDS.
|
||||||
|
@ -5012,16 +5011,6 @@ def gather_subscriptions_helper(user_profile: UserProfile,
|
||||||
stream_ids = {sub["stream_id"] for sub in sub_dicts}
|
stream_ids = {sub["stream_id"] for sub in sub_dicts}
|
||||||
recent_traffic = get_streams_traffic(stream_ids=stream_ids)
|
recent_traffic = get_streams_traffic(stream_ids=stream_ids)
|
||||||
|
|
||||||
stream_dicts = [stream for stream in all_streams if stream['id'] in stream_ids]
|
|
||||||
stream_hash = {}
|
|
||||||
for stream in stream_dicts:
|
|
||||||
stream_hash[stream["id"]] = stream
|
|
||||||
|
|
||||||
for sub in sub_dicts:
|
|
||||||
stream = stream_hash.get(sub["stream_id"])
|
|
||||||
if stream:
|
|
||||||
sub["is_web_public"] = stream.get("is_web_public", False)
|
|
||||||
|
|
||||||
subscribed = []
|
subscribed = []
|
||||||
unsubscribed = []
|
unsubscribed = []
|
||||||
never_subscribed = []
|
never_subscribed = []
|
||||||
|
|
Loading…
Reference in New Issue