mirror of
https://github.com/zulip/zulip.git
synced 2025-11-13 02:17:19 +00:00
mention: Allow linking archived streams.
Now that they are not completely inaccessible, there's no reason to disallow this.
This commit is contained in:
@@ -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.lib.users import get_inaccessible_user_ids
|
||||||
from zerver.models import NamedUserGroup, UserProfile
|
from zerver.models import NamedUserGroup, UserProfile
|
||||||
from zerver.models.groups import SystemGroups
|
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\'\"\(\{\[\/<])"
|
BEFORE_MENTION_ALLOWED_REGEX = r"(?<![^\s\'\"\(\{\[\/<])"
|
||||||
|
|
||||||
@@ -162,7 +162,7 @@ class MentionBackend:
|
|||||||
q_list = {Q(name=name) for name in unseen_stream_names}
|
q_list = {Q(name=name) for name in unseen_stream_names}
|
||||||
if acting_user is None:
|
if acting_user is None:
|
||||||
rows = (
|
rows = (
|
||||||
get_linkable_streams(
|
Stream.objects.filter(
|
||||||
realm_id=self.realm_id,
|
realm_id=self.realm_id,
|
||||||
)
|
)
|
||||||
.filter(
|
.filter(
|
||||||
@@ -180,7 +180,7 @@ class MentionBackend:
|
|||||||
authorization = filter_stream_authorization(
|
authorization = filter_stream_authorization(
|
||||||
acting_user,
|
acting_user,
|
||||||
list(
|
list(
|
||||||
get_linkable_streams(
|
Stream.objects.filter(
|
||||||
realm_id=self.realm_id,
|
realm_id=self.realm_id,
|
||||||
).filter(
|
).filter(
|
||||||
functools.reduce(lambda a, b: a | b, q_list),
|
functools.reduce(lambda a, b: a | b, q_list),
|
||||||
|
|||||||
@@ -248,16 +248,6 @@ def get_all_streams(realm: Realm, include_archived_channels: bool = True) -> Que
|
|||||||
return Stream.objects.filter(realm=realm)
|
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:
|
def get_stream(stream_name: str, realm: Realm) -> Stream:
|
||||||
"""
|
"""
|
||||||
Callers that don't have a Realm object already available should use
|
Callers that don't have a Realm object already available should use
|
||||||
|
|||||||
Reference in New Issue
Block a user