35 lines
867 B
Python
35 lines
867 B
Python
from dataclasses import dataclass
|
|
from datetime import datetime
|
|
from uuid import UUID
|
|
|
|
HISTORY_FILE_NAME = 'history.md'
|
|
|
|
|
|
@dataclass(frozen=True, slots=True)
|
|
class ChatAttachmentName:
|
|
value: str
|
|
|
|
def __post_init__(self) -> None:
|
|
if not self.value or self.value in {'.', '..'}:
|
|
raise ValueError('invalid attachment name')
|
|
if '/' in self.value or '\\' in self.value:
|
|
raise ValueError('invalid attachment name')
|
|
if self.value == HISTORY_FILE_NAME:
|
|
raise ValueError('reserved attachment name')
|
|
|
|
|
|
@dataclass(frozen=True, slots=True)
|
|
class Chat:
|
|
chat_id: UUID
|
|
workspace_id: UUID
|
|
created_at: datetime
|
|
|
|
|
|
@dataclass(frozen=True, slots=True)
|
|
class ChatFile:
|
|
file_id: UUID
|
|
chat_id: UUID
|
|
name: ChatAttachmentName
|
|
content_type: str | None
|
|
size_bytes: int
|
|
created_at: datetime
|