mirror of
https://github.com/zulip/zulip.git
synced 2026-07-09 21:21:47 +08:00
Add a maximum message length of 10000 characters.
(imported from commit a07c872d612521c9792be8dc704a9cfd6c752c75)
This commit is contained in:
parent
19108929a7
commit
100df7e349
@ -24,6 +24,7 @@ import re
|
||||
from django.utils.html import escape
|
||||
|
||||
MAX_SUBJECT_LENGTH = 60
|
||||
MAX_MESSAGE_LENGTH = 10000
|
||||
|
||||
@cache_with_key(lambda self: 'display_recipient_dict:%d' % (self.id,))
|
||||
def get_display_recipient(recipient):
|
||||
@ -556,7 +557,9 @@ def do_send_message(message, no_log=False):
|
||||
users = simplejson.dumps([str(user.id) for user in recipients])))
|
||||
|
||||
def internal_send_message(sender_email, recipient_type, recipient_name,
|
||||
subject, content):
|
||||
subject, content):
|
||||
if len(content) > MAX_MESSAGE_LENGTH:
|
||||
content = content[0:3900] + "\n\n[message was too long and has been truncated]"
|
||||
message = Message()
|
||||
message.sender = UserProfile.objects.get(user__email=sender_email)
|
||||
message.recipient = Recipient.objects.get(type_id=create_stream_if_needed(
|
||||
|
||||
@ -17,7 +17,7 @@ from zephyr.models import Message, UserProfile, Stream, Subscription, \
|
||||
create_mit_user_if_needed, create_stream_if_needed, StreamColor, \
|
||||
PreregistrationUser, get_client, MitUser, User, UserActivity, \
|
||||
log_subscription_property_change, internal_send_message, \
|
||||
MAX_SUBJECT_LENGTH
|
||||
MAX_SUBJECT_LENGTH, MAX_MESSAGE_LENGTH
|
||||
from zephyr.forms import RegistrationForm, HomepageForm, is_unique, \
|
||||
is_active
|
||||
from django.views.decorators.csrf import csrf_exempt
|
||||
@ -607,6 +607,8 @@ def send_message_backend(request, user_profile, client,
|
||||
|
||||
if len(message_to) == 0:
|
||||
return json_error("Message must have recipients.")
|
||||
if len(message_content) > MAX_MESSAGE_LENGTH:
|
||||
return json_error("Message too long.")
|
||||
|
||||
if client.name == "zephyr_mirror":
|
||||
# Here's how security works for non-superuser mirroring:
|
||||
|
||||
Loading…
Reference in New Issue
Block a user