Zulip server and web application. Open-source team chat that helps teams stay productive and focused.
typing: Add none-checks for stream.recipient_id.
Zixuan James Li058dab581824
diff --git a/zerver/actions/message_edit.py b/zerver/actions/message_edit.pyindex 1772f4aceb9..d16a7118134 100644--- a/zerver/actions/message_edit.py+++ b/zerver/actions/message_edit.py@@ -506,6 +506,7 @@ def do_update_message(edit_history_event["prev_stream"] = stream_being_edited.idedit_history_event["stream"] = new_stream.idevent[ORIG_TOPIC] = orig_topic_name+ assert new_stream.recipient_id is not Nonetarget_message.recipient_id = new_stream.recipient_idevent["new_stream_id"] = new_stream.id@@ -762,6 +763,7 @@ def do_update_message(# query. But it's nice to reuse code, and this bulk# operation is likely cheaper than a `GET /messages`# unless the topic has thousands of messages of history.+ assert stream_being_edited.recipient_id is not Noneunmoved_messages = messages_for_topic(stream_being_edited.recipient_id,orig_topic_name,diff --git a/zerver/actions/streams.py b/zerver/actions/streams.pyindex 51ea3d53cfd..6b3602b7037 100644--- a/zerver/actions/streams.py+++ b/zerver/actions/streams.py@@ -789,6 +789,7 @@ def do_change_stream_permission(if old_invite_only_value != stream.invite_only:# Reset the Attachment.is_realm_public cache for all# messages in the stream whose permissions were changed.+ assert stream.recipient_id is not NoneAttachment.objects.filter(messages__recipient_id=stream.recipient_id).update(is_realm_public=None)@@ -832,6 +833,7 @@ def do_change_stream_permission(if old_is_web_public_value != stream.is_web_public:# Reset the Attachment.is_realm_public cache for all# messages in the stream whose permissions were changed.+ assert stream.recipient_id is not NoneAttachment.objects.filter(messages__recipient_id=stream.recipient_id).update(is_web_public=None)diff --git a/zerver/actions/user_topics.py b/zerver/actions/user_topics.pyindex 5e18c90139e..ec00e5db7ac 100644--- a/zerver/actions/user_topics.py+++ b/zerver/actions/user_topics.py@@ -19,6 +19,7 @@ def do_mute_topic() -> None:if date_muted is None:date_muted = timezone_now()+ assert stream.recipient_id is not Noneadd_topic_mute(user_profile,stream.id,diff --git a/zerver/lib/streams.py b/zerver/lib/streams.pyindex f0e5d835ccb..f98044857b3 100644--- a/zerver/lib/streams.py+++ b/zerver/lib/streams.py@@ -358,6 +358,7 @@ def access_stream_common(raise AssertionError("user_profile and stream realms don't match")try:+ assert stream.recipient_id is not Nonesub = Subscription.objects.get(user_profile=user_profile, recipient_id=stream.recipient_id, active=require_active)diff --git a/zerver/lib/test_helpers.py b/zerver/lib/test_helpers.pyindex 61bf77d00a8..051b3ed6ed1 100644--- a/zerver/lib/test_helpers.py+++ b/zerver/lib/test_helpers.py@@ -271,6 +271,7 @@ def most_recent_message(user_profile: UserProfile) -> Message:def get_subscription(stream_name: str, user_profile: UserProfile) -> Subscription:stream = get_stream(stream_name, user_profile.realm)recipient_id = stream.recipient_id+ assert recipient_id is not Nonereturn Subscription.objects.get(user_profile=user_profile, recipient_id=recipient_id, active=True)diff --git a/zerver/lib/user_topics.py b/zerver/lib/user_topics.pyindex 0ead16824ed..18595a8ad86 100644--- a/zerver/lib/user_topics.py+++ b/zerver/lib/user_topics.py@@ -49,6 +49,7 @@ def set_topic_mutes(for stream_name, topic_name in muted_topics:stream = get_stream(stream_name, user_profile.realm)recipient_id = stream.recipient_id+ assert recipient_id is not Noneadd_topic_mute(user_profile=user_profile,diff --git a/zerver/views/streams.py b/zerver/views/streams.pyindex ec573b28893..d301bddf60d 100644--- a/zerver/views/streams.py+++ b/zerver/views/streams.py@@ -792,6 +792,7 @@ def get_topics_backend((stream, sub) = access_stream_by_id(user_profile, stream_id)+ assert stream.recipient_id is not Noneresult = get_topic_history_for_stream(user_profile=user_profile,recipient_id=stream.recipient_id,