streams: Remove duplicates of get_web_public_streams_queryset.

This is a somewhat subtle function, that deserves a few comments
explaining subtle details of its logic, and there's no good reason to
have multiple copies of that logic that are slightly inconsistent.

Because the main changes here are just checking for invariant
failures, the behavioral change here should be limited to ensuring
deactivated streams are not considered available even if they were
tagged as web public streams before deactivation.
This commit is contained in:
Tim Abbott
2021-09-27 16:10:40 -07:00
committed by Tim Abbott
parent 272e81988b
commit e556481ba0
3 changed files with 22 additions and 8 deletions

View File

@@ -399,15 +399,20 @@ def get_public_streams_queryset(realm: Realm) -> "QuerySet[Stream]":
def get_web_public_streams_queryset(realm: Realm) -> "QuerySet[Stream]":
# In theory, is_web_public=True implies invite_only=False and
# history_public_to_subscribers=True, but it's safer to include
# this in the query.
# This should match the include_web_public code path in do_get_streams.
return Stream.objects.filter(
realm=realm,
is_web_public=True,
# In theory, nothing conflicts with allowing web-public access
# to deactivated streams. However, we should offer a way to
# review archived streams and adjust their settings before
# allowing that configuration to exist.
deactivated=False,
# In theory, is_web_public=True implies invite_only=False and
# history_public_to_subscribers=True, but it's safer to include
# these in the query.
invite_only=False,
history_public_to_subscribers=True,
is_web_public=True,
)