Zulip server and web application. Open-source team chat that helps teams stay productive and focused.
message-send: Deduplicate check of `settings.MAX_MESSAGE_LENGTH`.
Lauryn Menard06dd6f825469
diff --git a/zerver/actions/message_send.py b/zerver/actions/message_send.pyindex 735daabd4e0..45d3d8ed016 100644--- a/zerver/actions/message_send.py+++ b/zerver/actions/message_send.py@@ -1500,10 +1500,6 @@ def _internal_prep_message(messages together as one database query.Call do_send_messages with a list of the return values of this method."""- # Remove any null bytes from the content- if len(content) > settings.MAX_MESSAGE_LENGTH:- content = content[0:3900] + "\n\n[message was too long and has been truncated]"-# If we have a stream name, and the stream doesn't exist, we# create it here (though this code path should probably be removed# eventually, moving that responsibility to the caller). Ifdiff --git a/zerver/tests/test_message_send.py b/zerver/tests/test_message_send.pyindex 895d1e24345..2a918b944a9 100644--- a/zerver/tests/test_message_send.py+++ b/zerver/tests/test_message_send.py@@ -2258,14 +2258,15 @@ class InternalPrepTest(ZulipTestCase):def test_error_handling(self) -> None:sender = self.example_user("cordelia")recipient_user = self.example_user("hamlet")- content = "x" * 15000+ MAX_MESSAGE_LENGTH = settings.MAX_MESSAGE_LENGTH+ content = "x" * (MAX_MESSAGE_LENGTH + 10)result = internal_prep_private_message(sender=sender, recipient_user=recipient_user, content=content)assert result is not Nonemessage = result.message- self.assertIn("message was too long", message.content)+ self.assertIn("message truncated", message.content)# Simulate sending a message to somebody not in the# realm of the sender.