From e92d68fffed0e156fe8651680e70265af0de7b21 Mon Sep 17 00:00:00 2001 From: Tim Abbott Date: Fri, 7 Mar 2025 13:09:51 -0800 Subject: [PATCH] streams: Remove require_active in access_stream code path. This was confusingly doing an assertion about the subscription being active, not the channel. We could rename it to require_active_subscription. But it was only passed with a non-default value in b2cb443d243610dc590d8831e681305a111aa43f, and that call was removed in 378062cc83de66946ae88af6f6fee148f3c43765. --- analytics/views/stats.py | 1 - zerver/actions/message_edit.py | 4 +--- zerver/lib/streams.py | 7 +------ 3 files changed, 2 insertions(+), 10 deletions(-) diff --git a/analytics/views/stats.py b/analytics/views/stats.py index 57c00ae0b7..9911c0e457 100644 --- a/analytics/views/stats.py +++ b/analytics/views/stats.py @@ -185,7 +185,6 @@ def get_chart_data_for_stream( stream, ignored_sub = access_stream_by_id( user_profile, stream_id, - require_active=True, require_content_access=False, ) diff --git a/zerver/actions/message_edit.py b/zerver/actions/message_edit.py index e04e2107ac..468115f1cb 100644 --- a/zerver/actions/message_edit.py +++ b/zerver/actions/message_edit.py @@ -1339,9 +1339,7 @@ def build_message_edit_request( is_stream_edited = False target_stream = orig_stream if stream_id is not None: - target_stream = access_stream_by_id_for_message( - user_profile, stream_id, require_active=True - )[0] + target_stream = access_stream_by_id_for_message(user_profile, stream_id)[0] is_stream_edited = True return StreamMessageEditRequest( diff --git a/zerver/lib/streams.py b/zerver/lib/streams.py index 172a9ee36c..e035d4d2bf 100644 --- a/zerver/lib/streams.py +++ b/zerver/lib/streams.py @@ -765,7 +765,6 @@ def access_stream_common( user_profile: UserProfile, stream: Stream, error: str, - require_active: bool = True, require_content_access: bool = True, ) -> Subscription | None: """Common function for backend code where the target use attempts to @@ -782,7 +781,7 @@ def access_stream_common( try: assert stream.recipient_id is not None sub = Subscription.objects.get( - user_profile=user_profile, recipient_id=stream.recipient_id, active=require_active + user_profile=user_profile, recipient_id=stream.recipient_id, active=True ) except Subscription.DoesNotExist: sub = None @@ -803,7 +802,6 @@ def access_stream_common( def access_stream_by_id( user_profile: UserProfile, stream_id: int, - require_active: bool = True, require_content_access: bool = True, ) -> tuple[Stream, Subscription | None]: error = _("Invalid channel ID") @@ -816,7 +814,6 @@ def access_stream_by_id( user_profile, stream, error, - require_active=require_active, require_content_access=require_content_access, ) return (stream, sub) @@ -825,7 +822,6 @@ def access_stream_by_id( def access_stream_by_id_for_message( user_profile: UserProfile, stream_id: int, - require_active: bool = True, require_content_access: bool = True, ) -> tuple[Stream, Subscription | None]: """ @@ -842,7 +838,6 @@ def access_stream_by_id_for_message( user_profile, stream, error, - require_active=require_active, require_content_access=require_content_access, ) return (stream, sub)