Skip to content

Commit

Permalink
refactor: api_types/model: Move pre-ZFL53 lengths to api_types.
Browse files Browse the repository at this point in the history
Comment adjusted; Final applied to new constants.
  • Loading branch information
neiljp committed Apr 22, 2023
1 parent a89cb8a commit 99157c2
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 9 deletions.
13 changes: 12 additions & 1 deletion zulipterminal/api_types.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

from typing import Any, Dict, List, Optional, Union

from typing_extensions import Literal, NotRequired, TypedDict
from typing_extensions import Final, Literal, NotRequired, TypedDict

# These are documented in the zulip package (python-zulip-api repo)
from zulip import EditPropagateMode # one/all/later
Expand All @@ -22,6 +22,17 @@
TYPING_STARTED_WAIT_PERIOD = 10
TYPING_STOPPED_WAIT_PERIOD = 5


###############################################################################
# These values are in the register response from ZFL 53
# Before this feature level, they had the listed default (fixed) values
# (strictly, the stream value was available, under a different name)

MAX_STREAM_NAME_LENGTH: Final = 60
MAX_TOPIC_NAME_LENGTH: Final = 60
MAX_MESSAGE_LENGTH: Final = 10000


###############################################################################
# Core message types (used in Composition and Message below)

Expand Down
11 changes: 3 additions & 8 deletions zulipterminal/model.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,9 @@

from zulipterminal import unicode_emojis
from zulipterminal.api_types import (
MAX_MESSAGE_LENGTH,
MAX_STREAM_NAME_LENGTH,
MAX_TOPIC_NAME_LENGTH,
Composition,
EditPropagateMode,
Event,
Expand Down Expand Up @@ -70,14 +73,6 @@

OFFLINE_THRESHOLD_SECS = 140

# Adapted from zerver/models.py
# These fields have migrated to the API inside the Realm object
# in ZFL 53. To allow backporting to earlier server versions, we
# define these hard-coded parameters.
MAX_STREAM_NAME_LENGTH = 60
MAX_TOPIC_NAME_LENGTH = 60
MAX_MESSAGE_LENGTH = 10000


class ServerConnectionFailure(Exception):
pass
Expand Down

0 comments on commit 99157c2

Please sign in to comment.