From ffe21bef8dd8f1dbcd7aa0dd1805733e97bdb6d6 Mon Sep 17 00:00:00 2001 From: G30 <50341825+silentoplayz@users.noreply.github.com> Date: Fri, 25 Sep 2026 23:27:49 -0400 Subject: [PATCH] fix: remove the share links of chats deleted along with their folder (#31306) --- backend/open_webui/models/chats.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/backend/open_webui/models/chats.py b/backend/open_webui/models/chats.py index d90f52e4c9..c5620f0cfe 100644 --- a/backend/open_webui/models/chats.py +++ b/backend/open_webui/models/chats.py @@ -2522,6 +2522,8 @@ class ChatTable: async def delete_chats_by_user_id_and_folder_id( self, user_id: str, folder_id: str, db: AsyncSession | None = None ) -> bool: + from open_webui.models.shared_chats import SharedChat as SharedChatTable + try: async with get_async_db_context(db) as session: chat_ids_stmt = select(Chat.id).filter_by(user_id=user_id, folder_id=folder_id) @@ -2529,6 +2531,7 @@ class ChatTable: update(AutomationRun).filter(AutomationRun.chat_id.in_(chat_ids_stmt)).values(chat_id=None) ) await session.execute(delete(ChatMessage).filter(ChatMessage.chat_id.in_(chat_ids_stmt))) + await session.execute(delete(SharedChatTable).filter(SharedChatTable.chat_id.in_(chat_ids_stmt))) await session.execute(delete(Chat).filter_by(user_id=user_id, folder_id=folder_id)) await session.commit()