zerver: API to create channel.

Fixes #16206.

Co-authored-by: Sahil Batra <sahil@zulip.com>
Co-authored-by: Steve Howell <showell@zulip.com>
Signed-off-by: apoorvapendse <apoorvavpendse@gmail.com>
This commit is contained in:
apoorvapendse
2025-07-02 11:26:37 +05:30
committed by Tim Abbott
parent 6ef2591b47
commit 6203861529
12 changed files with 750 additions and 22 deletions

View File

@@ -17,6 +17,7 @@ class ErrorCode(Enum):
BAD_NARROW = auto()
CANNOT_DEACTIVATE_LAST_USER = auto()
MISSING_HTTP_EVENT_HEADER = auto()
CHANNEL_ALREADY_EXISTS = auto()
STREAM_DOES_NOT_EXIST = auto()
UNAUTHORIZED_PRINCIPAL = auto()
UNSUPPORTED_WEBHOOK_EVENT_TYPE = auto()
@@ -174,6 +175,20 @@ class UnauthorizedError(JsonableError):
return extra_headers_dict
class ChannelExistsError(JsonableError):
code = ErrorCode.CHANNEL_ALREADY_EXISTS
http_status_code = 409
data_fields = ["channel_name"]
def __init__(self, channel_name: str) -> None:
self.channel_name = channel_name
@staticmethod
@override
def msg_format() -> str:
return _("Channel '{channel_name}' already exists")
class StreamDoesNotExistError(JsonableError):
code = ErrorCode.STREAM_DOES_NOT_EXIST
data_fields = ["stream"]