mirror of
https://github.com/open-webui/open-webui.git
synced 2026-10-05 02:41:34 +00:00
fix: shared chats can't open new files attached together with a file already in the chat (#31650)
When files were attached to a chat message and one of them was already attached to that chat (on the same message or another one), none of the new files were recorded as part of the chat, and nothing showed up in the logs. The sender still saw every file in their own chat, but anyone opening a shared copy of the chat could not open the new ones. Files already attached to the chat are now skipped and the new ones are recorded normally. Fixes #31648
This commit is contained in:
parent
6c322941d1
commit
3d43a497b5
1 changed files with 4 additions and 4 deletions
|
|
@ -2585,11 +2585,11 @@ class ChatTable:
|
|||
if not file_ids:
|
||||
return None
|
||||
|
||||
chat_message_file_ids = {
|
||||
item.id for item in await self.get_chat_files_by_chat_id_and_message_id(chat_id, message_id, db=db)
|
||||
}
|
||||
async with get_async_db_context(db) as session:
|
||||
result = await session.execute(select(ChatFile.file_id).filter_by(chat_id=chat_id))
|
||||
chat_file_ids = set(result.scalars().all())
|
||||
# Remove duplicates and existing file_ids
|
||||
file_ids = list({file_id for file_id in file_ids if file_id and file_id not in chat_message_file_ids})
|
||||
file_ids = list({file_id for file_id in file_ids if file_id and file_id not in chat_file_ids})
|
||||
if not file_ids:
|
||||
return None
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue