diff --git a/zerver/lib/events.py b/zerver/lib/events.py index a9bb5380b9..95ee9af6d2 100644 --- a/zerver/lib/events.py +++ b/zerver/lib/events.py @@ -68,7 +68,6 @@ from zerver.lib.users import ( max_message_id_for_user, ) from zerver.models import ( - MAX_TOPIC_NAME_LENGTH, Client, CustomProfileField, Draft, @@ -87,6 +86,7 @@ from zerver.models import ( get_realm_playgrounds, linkifiers_for_realm, ) +from zerver.models.constants import MAX_TOPIC_NAME_LENGTH from zerver.tornado.django_api import get_user_events, request_event_queue from zproject.backends import email_auth_enabled, password_auth_enabled diff --git a/zerver/lib/message.py b/zerver/lib/message.py index a1c2fab199..322c17d05c 100644 --- a/zerver/lib/message.py +++ b/zerver/lib/message.py @@ -63,7 +63,6 @@ from zerver.lib.user_groups import is_user_in_group from zerver.lib.user_topics import build_get_topic_visibility_policy, get_topic_visibility_policy from zerver.lib.users import get_inaccessible_user_ids from zerver.models import ( - MAX_TOPIC_NAME_LENGTH, Message, Reaction, Realm, @@ -80,6 +79,7 @@ from zerver.models import ( get_usermessage_by_message_id, query_for_ids, ) +from zerver.models.constants import MAX_TOPIC_NAME_LENGTH class MessageDetailsDict(TypedDict, total=False): diff --git a/zerver/models/__init__.py b/zerver/models/__init__.py index cb337ea3d9..fd999cf69c 100644 --- a/zerver/models/__init__.py +++ b/zerver/models/__init__.py @@ -118,9 +118,7 @@ from zerver.lib.validator import ( check_url, validate_select_field, ) - -MAX_TOPIC_NAME_LENGTH = 60 -MAX_LANGUAGE_ID_LENGTH: int = 50 +from zerver.models.constants import MAX_LANGUAGE_ID_LENGTH, MAX_TOPIC_NAME_LENGTH SECONDS_PER_DAY = 86400 diff --git a/zerver/models/constants.py b/zerver/models/constants.py new file mode 100644 index 0000000000..6445f5ed1e --- /dev/null +++ b/zerver/models/constants.py @@ -0,0 +1,2 @@ +MAX_TOPIC_NAME_LENGTH = 60 +MAX_LANGUAGE_ID_LENGTH: int = 50 diff --git a/zerver/tests/test_message_edit.py b/zerver/tests/test_message_edit.py index 97673f9c32..22d7622206 100644 --- a/zerver/tests/test_message_edit.py +++ b/zerver/tests/test_message_edit.py @@ -31,7 +31,6 @@ from zerver.lib.user_topics import ( ) from zerver.lib.utils import assert_is_not_none from zerver.models import ( - MAX_TOPIC_NAME_LENGTH, Message, Realm, Stream, @@ -43,6 +42,7 @@ from zerver.models import ( get_realm, get_stream, ) +from zerver.models.constants import MAX_TOPIC_NAME_LENGTH if TYPE_CHECKING: from django.test.client import _MonkeyPatchedWSGIResponse as TestHttpResponse diff --git a/zerver/tests/test_message_send.py b/zerver/tests/test_message_send.py index 8992a087d8..51d649ce96 100644 --- a/zerver/tests/test_message_send.py +++ b/zerver/tests/test_message_send.py @@ -47,7 +47,6 @@ from zerver.lib.test_helpers import ( ) from zerver.lib.timestamp import datetime_to_timestamp from zerver.models import ( - MAX_TOPIC_NAME_LENGTH, Message, Realm, RealmDomain, @@ -64,6 +63,7 @@ from zerver.models import ( get_system_bot, get_user, ) +from zerver.models.constants import MAX_TOPIC_NAME_LENGTH from zerver.views.message_send import InvalidMirrorInputError diff --git a/zerver/views/registration.py b/zerver/views/registration.py index 4ac7992456..c6872e8455 100644 --- a/zerver/views/registration.py +++ b/zerver/views/registration.py @@ -73,7 +73,6 @@ from zerver.lib.validator import ( ) from zerver.lib.zephyr import compute_mit_user_fullname from zerver.models import ( - MAX_LANGUAGE_ID_LENGTH, DisposableEmailError, DomainNotAllowedForRealmError, EmailContainsPlusError, @@ -91,6 +90,7 @@ from zerver.models import ( get_user_by_delivery_email, name_changes_disabled, ) +from zerver.models.constants import MAX_LANGUAGE_ID_LENGTH from zerver.views.auth import ( create_preregistration_realm, create_preregistration_user, diff --git a/zerver/webhooks/splunk/view.py b/zerver/webhooks/splunk/view.py index ba8d9b612f..afe61492aa 100644 --- a/zerver/webhooks/splunk/view.py +++ b/zerver/webhooks/splunk/view.py @@ -6,7 +6,8 @@ from zerver.lib.response import json_success from zerver.lib.typed_endpoint import JsonBodyPayload, typed_endpoint from zerver.lib.validator import WildValue, check_string from zerver.lib.webhooks.common import check_send_webhook_message -from zerver.models import MAX_TOPIC_NAME_LENGTH, UserProfile +from zerver.models import UserProfile +from zerver.models.constants import MAX_TOPIC_NAME_LENGTH MESSAGE_TEMPLATE = """ Splunk alert from saved search: