settings: Make MAX_MESSAGE_LENGTH a server-level setting.

This will offer users who are self-hosting to adjust
this value. Moreover, this will help to reduce the
overall time taken to test `test_markdown.py` (since
this can be now overridden with `override_settings`
Django decorator).

This is done as a prep commit for #18641.
This commit is contained in:
akshatdalton
2021-06-03 13:04:22 +00:00
committed by Tim Abbott
parent 9b9d30152a
commit 7df62ebbaf
8 changed files with 14 additions and 11 deletions

View File

@@ -187,7 +187,6 @@ from zerver.lib.utils import generate_api_key, log_statsd_event
from zerver.lib.validator import check_widget_content
from zerver.lib.widget import do_widget_post_save_actions, is_widget_message
from zerver.models import (
MAX_MESSAGE_LENGTH,
Attachment,
Client,
CustomProfileField,
@@ -3197,7 +3196,7 @@ def _internal_prep_message(
Call do_send_messages with a list of the return values of this method.
"""
# Remove any null bytes from the content
if len(content) > MAX_MESSAGE_LENGTH:
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