mirror of
https://github.com/open-webui/open-webui.git
synced 2026-10-02 02:12:25 +00:00
refac: derive a forked chat's folder from the caller's write access (#30069)
A fork copied the source chat's folder id unchanged. It now keeps that folder only when the caller has write access to it, matching what chat creation and chat moves already do, and is created outside any folder otherwise.
This commit is contained in:
parent
befdd86eb1
commit
48fb2b84ba
1 changed files with 6 additions and 1 deletions
|
|
@ -1732,10 +1732,15 @@ async def fork_chat_by_id(
|
|||
'forked_from_message_id': source_message_id,
|
||||
}
|
||||
|
||||
# The source chat's folder may no longer be writable by the caller.
|
||||
folder_id = chat.folder_id
|
||||
if folder_id is not None and not await has_folder_write_access(user.id, folder_id, db=db):
|
||||
folder_id = None
|
||||
|
||||
fork = await Chats.insert_new_chat(
|
||||
str(uuid4()),
|
||||
user.id,
|
||||
ChatForm(chat=updated_chat, folder_id=chat.folder_id),
|
||||
ChatForm(chat=updated_chat, folder_id=folder_id),
|
||||
db=db,
|
||||
internal_meta=meta,
|
||||
)
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue