Skip to content

armgit / zulip

Public Imported from GitHub
0

Zulip server and web application. Open-source team chat that helps teams stay productive and focused.

stream: Fix error handling in access_stream_for_send_message.

sahil8393df87d0901ac
diff --git a/zerver/lib/streams.py b/zerver/lib/streams.py
index eee28ac1ecd..fd984be121c 100644
--- a/zerver/lib/streams.py
+++ b/zerver/lib/streams.py
@@ -205,7 +205,7 @@ def access_stream_for_send_message(
elif stream.stream_post_policy != Stream.STREAM_POST_POLICY_EVERYONE and sender.is_guest:
raise JsonableError(_("Guests cannot send to this stream."))
elif stream.stream_post_policy == Stream.STREAM_POST_POLICY_RESTRICT_NEW_MEMBERS:
- if sender.is_bot and (sender.bot_owner is not None and sender.bot_owner.is_new_member):
+ if sender.is_bot and (sender.bot_owner is None or sender.bot_owner.is_new_member):
raise JsonableError(_("New members cannot send to this stream."))
elif sender.is_new_member:
raise JsonableError(_("New members cannot send to this stream."))
diff --git a/zerver/tests/test_message_send.py b/zerver/tests/test_message_send.py
index 8b42c95ceb0..40b1ce6a9d8 100644
--- a/zerver/tests/test_message_send.py
+++ b/zerver/tests/test_message_send.py
@@ -279,7 +279,8 @@ class MessagePOSTTest(ZulipTestCase):
non_admin_owned_bot, stream_name, "New members cannot send to this stream."
)
- # Bots without owner (except cross realm bot) cannot send to announcement only stream
+ # Bots without owner (except cross realm bot) cannot send to STREAM_POST_POLICY_ADMINS_ONLY and
+ # STREAM_POST_POLICY_RESTRICT_NEW_MEMBERS streams
bot_without_owner = do_create_user(
password="",