Skip to content

armgit / zulip

Public Imported from GitHub
0

Zulip server and web application. Open-source team chat that helps teams stay productive and focused.

message_fetch: Refactor public-streams query logic.

Tim Abbott35bd14574d36
diff --git a/zerver/views/message_fetch.py b/zerver/views/message_fetch.py
index c19fd9f3e62..da765163bf8 100644
--- a/zerver/views/message_fetch.py
+++ b/zerver/views/message_fetch.py
@@ -268,10 +268,13 @@ class NarrowBuilder:
if operand == 'public':
# Get all both subscribed and non subscribed public streams
# but exclude any private subscribed streams.
- recipient_ids = get_public_streams_queryset(self.realm).values_list("recipient_id", flat=True).order_by('id')
- cond = column("recipient_id").in_(recipient_ids)
- return query.where(maybe_negate(cond))
- raise BadNarrowOperator('unknown streams operand ' + operand)
+ recipient_queryset = get_public_streams_queryset(self.realm)
+ else:
+ raise BadNarrowOperator('unknown streams operand ' + operand)
+
+ recipient_ids = recipient_queryset.values_list("recipient_id", flat=True).order_by('id')
+ cond = column("recipient_id").in_(recipient_ids)
+ return query.where(maybe_negate(cond))
def by_topic(self, query: Query, operand: str, maybe_negate: ConditionTransform) -> Query:
if self.user_profile.realm.is_zephyr_mirror_realm: