fix: resolve project_id from task when broadcasting task messages
Some checks failed
Deploy Tracker / deploy (push) Failing after 4s
Some checks failed
Deploy Tracker / deploy (push) Failing after 4s
This commit is contained in:
parent
4d35e35b5e
commit
f94af46895
@ -128,6 +128,7 @@ async def create_message(req: MessageCreate, request: Request, db: AsyncSession
|
||||
|
||||
# Broadcast via WebSocket
|
||||
from ..ws.manager import manager
|
||||
from ..models.task import Task
|
||||
|
||||
project_id = None
|
||||
if req.chat_id:
|
||||
@ -142,6 +143,13 @@ async def create_message(req: MessageCreate, request: Request, db: AsyncSession
|
||||
)
|
||||
return message_out(msg)
|
||||
|
||||
# If no chat_id but task_id — resolve project from task
|
||||
if not project_id and req.task_id:
|
||||
task_result = await db.execute(select(Task).where(Task.id == uuid.UUID(req.task_id)))
|
||||
task = task_result.scalar_one_or_none()
|
||||
if task and task.project_id:
|
||||
project_id = str(task.project_id)
|
||||
|
||||
if project_id:
|
||||
await manager.broadcast_message(project_id, msg_data, author_id=author_id)
|
||||
else:
|
||||
|
||||
Loading…
Reference in New Issue
Block a user