Zulip server and web application. Open-source team chat that helps teams stay productive and focused.
refactor: Extract get_linkable_streams.
Steve Howell0359c083d132
diff --git a/zerver/lib/mention.py b/zerver/lib/mention.pyindex e144b5d09ef..39aa842d9cd 100644--- a/zerver/lib/mention.py+++ b/zerver/lib/mention.py@@ -5,7 +5,7 @@ from typing import Dict, List, Match, Optional, Set, Tuplefrom django.db.models import Q-from zerver.models import Realm, UserGroup, UserProfile, get_active_streams+from zerver.models import Realm, UserGroup, UserProfile, get_linkable_streams# Match multi-word string between @** ** or match any one-word# sequences after @@@ -206,8 +206,8 @@ def get_stream_name_map(realm: Realm, stream_names: Set[str]) -> Dict[str, int]:q_list = {Q(name=name) for name in stream_names}rows = (- get_active_streams(- realm=realm,+ get_linkable_streams(+ realm_id=realm.id,).filter(functools.reduce(lambda a, b: a | b, q_list),diff --git a/zerver/models.py b/zerver/models.pyindex 3173782d479..9a720aa3e88 100644--- a/zerver/models.py+++ b/zerver/models.py@@ -2476,6 +2476,16 @@ def get_active_streams(realm: Optional[Realm]) -> QuerySet:return Stream.objects.filter(realm=realm, deactivated=False)+def get_linkable_streams(realm_id: int) -> QuerySet:+ """+ This returns the streams that we are allowed to linkify using+ something like "#frontend" in our markup. For now the business+ rule is that you can link any stream in the realm that hasn't+ been deactivated (similar to how get_active_streams works).+ """+ return Stream.objects.filter(realm_id=realm_id, deactivated=False)++def get_stream(stream_name: str, realm: Realm) -> Stream:"""Callers that don't have a Realm object already available should use