mirror of https://github.com/zulip/zulip.git
Truncate the tutorial stream name to fit the DB max stream name length.
(imported from commit e267656337f97d3ea14e14e957a405cf4fd2d06c)
This commit is contained in:
parent
6263c9ba1e
commit
37e58b613d
|
@ -279,7 +279,7 @@ def check_send_message(sender, client, message_type_name, message_to,
|
|||
stream_name = message_to[0].strip()
|
||||
if stream_name == "":
|
||||
return "Stream can't be empty"
|
||||
if len(stream_name) > 30:
|
||||
if len(stream_name) > Stream.MAX_NAME_LENGTH:
|
||||
return "Stream name too long"
|
||||
if not valid_stream_name(stream_name):
|
||||
return "Invalid stream name"
|
||||
|
|
|
@ -102,7 +102,8 @@ class MitUser(models.Model):
|
|||
status = models.IntegerField(default=0)
|
||||
|
||||
class Stream(models.Model):
|
||||
name = models.CharField(max_length=30, db_index=True)
|
||||
MAX_NAME_LENGTH = 30
|
||||
name = models.CharField(max_length=MAX_NAME_LENGTH, db_index=True)
|
||||
realm = models.ForeignKey(Realm, db_index=True)
|
||||
invite_only = models.NullBooleanField(default=False)
|
||||
|
||||
|
|
|
@ -121,6 +121,7 @@ var script = [];
|
|||
|
||||
function make_script() {
|
||||
my_tutorial_stream = 'tutorial-' + email.split('@')[0];
|
||||
my_tutorial_stream = my_tutorial_stream.substring(0, 30);
|
||||
|
||||
// Try to guess at one of your main streams.
|
||||
// This is problematic because it might end up being 'commits' or something.
|
||||
|
|
|
@ -80,7 +80,7 @@ def list_to_streams(streams_raw, user_profile, autocreate=False, invite_only=Fal
|
|||
stream_set = set(stream_name.strip() for stream_name in streams_raw)
|
||||
rejects = []
|
||||
for stream_name in stream_set:
|
||||
if len(stream_name) > 30:
|
||||
if len(stream_name) > Stream.MAX_NAME_LENGTH:
|
||||
raise JsonableError("Stream name (%s) too long." % (stream_name,))
|
||||
if not valid_stream_name(stream_name):
|
||||
raise JsonableError("Invalid stream name (%s)." % (stream_name,))
|
||||
|
@ -751,6 +751,7 @@ def json_tutorial_send_message(request, user_profile,
|
|||
return json_success()
|
||||
elif message_type_name == 'stream':
|
||||
tutorial_stream_name = 'tutorial-%s' % user_profile.user.email.split('@')[0]
|
||||
tutorial_stream_name = tutorial_stream_name[:Stream.MAX_NAME_LENGTH]
|
||||
## TODO: For open realms, we need to use the full name here,
|
||||
## so that me@gmail.com and me@hotmail.com don't get the same stream.
|
||||
internal_send_message(sender_name,
|
||||
|
@ -881,7 +882,7 @@ def add_subscriptions_backend(request, user_profile,
|
|||
stream_names = []
|
||||
for stream_name in streams_raw:
|
||||
stream_name = stream_name.strip()
|
||||
if len(stream_name) > 30:
|
||||
if len(stream_name) > Stream.MAX_NAME_LENGTH:
|
||||
return json_error("Stream name (%s) too long." % (stream_name,))
|
||||
if not valid_stream_name(stream_name):
|
||||
return json_error("Invalid stream name (%s)." % (stream_name,))
|
||||
|
|
Loading…
Reference in New Issue