mention: Allow linking archived streams.

Now that they are not completely inaccessible, there's no reason to
disallow this.
This commit is contained in:
Tim Abbott
2025-01-30 17:31:59 -08:00
parent bd8b845a4d
commit 7c90d0a588
2 changed files with 3 additions and 13 deletions

View File

@@ -13,7 +13,7 @@ from zerver.lib.user_groups import get_root_id_annotated_recursive_subgroups_for
from zerver.lib.users import get_inaccessible_user_ids
from zerver.models import NamedUserGroup, UserProfile
from zerver.models.groups import SystemGroups
from zerver.models.streams import get_linkable_streams
from zerver.models.streams import Stream
BEFORE_MENTION_ALLOWED_REGEX = r"(?<![^\s\'\"\(\{\[\/<])"
@@ -162,7 +162,7 @@ class MentionBackend:
q_list = {Q(name=name) for name in unseen_stream_names}
if acting_user is None:
rows = (
get_linkable_streams(
Stream.objects.filter(
realm_id=self.realm_id,
)
.filter(
@@ -180,7 +180,7 @@ class MentionBackend:
authorization = filter_stream_authorization(
acting_user,
list(
get_linkable_streams(
Stream.objects.filter(
realm_id=self.realm_id,
).filter(
functools.reduce(lambda a, b: a | b, q_list),

View File

@@ -248,16 +248,6 @@ def get_all_streams(realm: Realm, include_archived_channels: bool = True) -> Que
return Stream.objects.filter(realm=realm)
def get_linkable_streams(realm_id: int) -> QuerySet[Stream]:
"""
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