mirror of
https://github.com/MODSetter/SurfSense.git
synced 2026-06-26 21:39:43 +02:00
display user avatar in shared chat messages
This commit is contained in:
parent
dcd36166fc
commit
83d6b735fa
4 changed files with 98 additions and 107 deletions
|
|
@ -411,13 +411,9 @@ async def get_thread_messages(
|
|||
Requires CHATS_READ permission.
|
||||
"""
|
||||
try:
|
||||
# Get thread with messages and their authors
|
||||
# Get thread first
|
||||
result = await session.execute(
|
||||
select(NewChatThread)
|
||||
.options(
|
||||
selectinload(NewChatThread.messages).selectinload(NewChatMessage.author)
|
||||
)
|
||||
.filter(NewChatThread.id == thread_id)
|
||||
select(NewChatThread).filter(NewChatThread.id == thread_id)
|
||||
)
|
||||
thread = result.scalars().first()
|
||||
|
||||
|
|
@ -436,6 +432,15 @@ async def get_thread_messages(
|
|||
# Check thread-level access based on visibility
|
||||
await check_thread_access(session, thread, user)
|
||||
|
||||
# Get messages with their authors loaded
|
||||
messages_result = await session.execute(
|
||||
select(NewChatMessage)
|
||||
.options(selectinload(NewChatMessage.author))
|
||||
.filter(NewChatMessage.thread_id == thread_id)
|
||||
.order_by(NewChatMessage.created_at)
|
||||
)
|
||||
db_messages = messages_result.scalars().all()
|
||||
|
||||
# Return messages in the format expected by assistant-ui
|
||||
messages = [
|
||||
NewChatMessageRead(
|
||||
|
|
@ -448,7 +453,7 @@ async def get_thread_messages(
|
|||
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
|
||||
for msg in db_messages
|
||||
]
|
||||
|
||||
return ThreadHistoryLoadResponse(messages=messages)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue