Zulip server and web application. Open-source team chat that helps teams stay productive and focused.
narrow: Do not error when given an empty DM recipient list.
Alex Vandiver2bfdccd06580
diff --git a/zerver/lib/narrow.py b/zerver/lib/narrow.pyindex 49f89aae062..043e90397af 100644--- a/zerver/lib/narrow.py+++ b/zerver/lib/narrow.py@@ -594,6 +594,9 @@ class NarrowBuilder:realm=self.realm,)+ if user_profiles == []:+ return query.where(maybe_negate(false()))+recipient = recipient_for_user_profiles(user_profiles=user_profiles,forwarded_mirror_message=False,diff --git a/zerver/tests/test_message_fetch.py b/zerver/tests/test_message_fetch.pyindex bd80a5dd5b2..d9c53b86562 100644--- a/zerver/tests/test_message_fetch.py+++ b/zerver/tests/test_message_fetch.py@@ -3920,6 +3920,18 @@ class GetOldMessagesTest(ZulipTestCase):]self.exercise_bad_narrow_operand("dm", invalid_operands)+ def test_bad_narrow_dm_empty_list(self) -> None:+ self.login("hamlet")+ post_params = {+ "anchor": "0",+ "num_before": "0",+ "num_after": "0",+ "narrow": orjson.dumps([{"operand": [], "operator": "dm"}]).decode(),+ }+ result = self.client_get("/json/messages", post_params)+ messages = self.assert_json_success(result)["messages"]+ self.assertEqual(messages, [])+def test_message_without_rendered_content(self) -> None:"""Older messages may not have rendered_content in the database"""m = self.get_last_message()