From a8918b9cca9c00d8fc0c9fa23035edf8e3d1ddff Mon Sep 17 00:00:00 2001 From: CREDO23 Date: Wed, 14 Jan 2026 18:36:48 +0200 Subject: [PATCH] include author info in message response --- surfsense_backend/app/routes/new_chat_routes.py | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/surfsense_backend/app/routes/new_chat_routes.py b/surfsense_backend/app/routes/new_chat_routes.py index b2c2bfe26..4ee515770 100644 --- a/surfsense_backend/app/routes/new_chat_routes.py +++ b/surfsense_backend/app/routes/new_chat_routes.py @@ -411,10 +411,12 @@ async def get_thread_messages( Requires CHATS_READ permission. """ try: - # Get thread with messages + # Get thread with messages and their authors result = await session.execute( select(NewChatThread) - .options(selectinload(NewChatThread.messages)) + .options( + selectinload(NewChatThread.messages).selectinload(NewChatMessage.author) + ) .filter(NewChatThread.id == thread_id) ) thread = result.scalars().first() @@ -442,6 +444,9 @@ async def get_thread_messages( role=msg.role, content=msg.content, created_at=msg.created_at, + author_id=msg.author_id, + author_display_name=msg.author.display_name if msg.author else None, + author_avatar_url=msg.author.avatar_url if msg.author else None, ) for msg in thread.messages ]