mirror of
https://github.com/MODSetter/SurfSense.git
synced 2026-06-02 19:55:18 +02:00
include author info in message response
This commit is contained in:
parent
e9d164007d
commit
a8918b9cca
1 changed files with 7 additions and 2 deletions
|
|
@ -411,10 +411,12 @@ async def get_thread_messages(
|
||||||
Requires CHATS_READ permission.
|
Requires CHATS_READ permission.
|
||||||
"""
|
"""
|
||||||
try:
|
try:
|
||||||
# Get thread with messages
|
# Get thread with messages and their authors
|
||||||
result = await session.execute(
|
result = await session.execute(
|
||||||
select(NewChatThread)
|
select(NewChatThread)
|
||||||
.options(selectinload(NewChatThread.messages))
|
.options(
|
||||||
|
selectinload(NewChatThread.messages).selectinload(NewChatMessage.author)
|
||||||
|
)
|
||||||
.filter(NewChatThread.id == thread_id)
|
.filter(NewChatThread.id == thread_id)
|
||||||
)
|
)
|
||||||
thread = result.scalars().first()
|
thread = result.scalars().first()
|
||||||
|
|
@ -442,6 +444,9 @@ async def get_thread_messages(
|
||||||
role=msg.role,
|
role=msg.role,
|
||||||
content=msg.content,
|
content=msg.content,
|
||||||
created_at=msg.created_at,
|
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
|
for msg in thread.messages
|
||||||
]
|
]
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue