mirror of
https://github.com/zulip/zulip.git
synced 2025-10-27 10:03:56 +00:00
user_groups: Add API restrictions for long user group names.
Previously we had database level restriction on length of user group names. Now we add the same restriction to API level as well, so we can return a better error response.
This commit is contained in:
@@ -101,6 +101,15 @@ def access_user_group_for_setting(
|
||||
return user_group
|
||||
|
||||
|
||||
def check_user_group_name(group_name: str) -> str:
|
||||
if len(group_name) > UserGroup.MAX_NAME_LENGTH:
|
||||
raise JsonableError(
|
||||
_("User group name cannot exceed {} characters.").format(UserGroup.MAX_NAME_LENGTH)
|
||||
)
|
||||
|
||||
return group_name
|
||||
|
||||
|
||||
def user_groups_in_realm_serialized(realm: Realm) -> List[UserGroupDict]:
|
||||
"""This function is used in do_events_register code path so this code
|
||||
should be performant. We need to do 2 database queries because
|
||||
|
||||
Reference in New Issue
Block a user