fix: unified message format (author object), CASCADE delete tasks, author_id nullable
Some checks failed
Deploy Tracker / deploy (push) Failing after 3s
Some checks failed
Deploy Tracker / deploy (push) Failing after 3s
This commit is contained in:
parent
2e36b26b05
commit
a4fcfe91b3
@ -34,8 +34,8 @@ class MessageOut(BaseModel):
|
||||
task_id: str | None = None
|
||||
parent_id: str | None = None
|
||||
author_type: str
|
||||
author_id: str
|
||||
author: dict | None = None # Member object for display
|
||||
author_id: str | None = None
|
||||
author: dict | None = None # {id, slug, name} — None for system messages
|
||||
content: str
|
||||
mentions: list[str] = []
|
||||
voice_url: str | None = None
|
||||
@ -174,9 +174,8 @@ async def create_message(req: MessageCreate, request: Request, db: AsyncSession
|
||||
"chat_id": req.chat_id,
|
||||
"task_id": req.task_id,
|
||||
"author_type": msg.author_type,
|
||||
"author_id": str(msg.author_id),
|
||||
"author_slug": author_slug,
|
||||
"author_name": author_name,
|
||||
"author_id": str(msg.author_id) if msg.author_id else None,
|
||||
"author": {"id": str(msg.author.id), "slug": msg.author.slug, "name": msg.author.name} if msg.author else None,
|
||||
"content": msg.content,
|
||||
"mentions": msg.mentions or [],
|
||||
"attachments": [
|
||||
|
||||
@ -545,7 +545,7 @@ async def reject_task(
|
||||
comment = Message(
|
||||
task_id=task.id,
|
||||
author_type=AuthorType.SYSTEM,
|
||||
author_id=current_member.id,
|
||||
author_id=None,
|
||||
content=f"Задача отклонена: {req.reason}",
|
||||
mentions=[],
|
||||
)
|
||||
|
||||
@ -35,7 +35,7 @@ class Message(Base):
|
||||
|
||||
# Context: one of chat_id or task_id must be set
|
||||
chat_id: Mapped[uuid.UUID | None] = mapped_column(UUID(as_uuid=True), ForeignKey("chats.id"))
|
||||
task_id: Mapped[uuid.UUID | None] = mapped_column(UUID(as_uuid=True), ForeignKey("tasks.id"))
|
||||
task_id: Mapped[uuid.UUID | None] = mapped_column(UUID(as_uuid=True), ForeignKey("tasks.id", ondelete="CASCADE"))
|
||||
|
||||
# Thread support
|
||||
parent_id: Mapped[uuid.UUID | None] = mapped_column(UUID(as_uuid=True), ForeignKey("messages.id"))
|
||||
|
||||
@ -45,7 +45,7 @@ class Task(Base):
|
||||
class Step(Base):
|
||||
__tablename__ = "steps"
|
||||
|
||||
task_id: Mapped[uuid.UUID] = mapped_column(UUID(as_uuid=True), ForeignKey("tasks.id"), nullable=False)
|
||||
task_id: Mapped[uuid.UUID] = mapped_column(UUID(as_uuid=True), ForeignKey("tasks.id", ondelete="CASCADE"), nullable=False)
|
||||
title: Mapped[str] = mapped_column(String(500), nullable=False)
|
||||
done: Mapped[bool] = mapped_column(Boolean, default=False)
|
||||
position: Mapped[int] = mapped_column(Integer, default=0)
|
||||
|
||||
@ -290,10 +290,10 @@ async def _handle_chat_send(session_id: str, data: dict):
|
||||
"task_id": task_id,
|
||||
"author_type": member.type,
|
||||
"author_id": str(member.id),
|
||||
"author_slug": member.slug,
|
||||
"author_name": member.name,
|
||||
"author": {"id": str(member.id), "slug": member.slug, "name": member.name},
|
||||
"content": content,
|
||||
"mentions": mentions,
|
||||
"attachments": [],
|
||||
"created_at": msg.created_at.isoformat(),
|
||||
}
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user