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:
Classic298 2026-09-16 21:42:03 +02:00 • committed by GitHub
parent befdd86eb1
commit 48fb2b84ba
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -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,
)