mirror of
https://github.com/open-webui/open-webui.git
synced 2026-09-27 09:46:07 -04:00
fix: restore tag rows after unarchiving all chats and remove unused ones after deleting all chats (#30453)
This commit is contained in:
@@ -716,8 +716,10 @@ async def delete_all_user_chats(
|
||||
detail=ERROR_MESSAGES.ACCESS_PROHIBITED,
|
||||
)
|
||||
|
||||
tag_ids = [tag.id for tag in await Tags.get_tags_by_user_id(user.id, db=db)]
|
||||
result = await Chats.delete_chats_by_user_id(user.id, db=db)
|
||||
if result:
|
||||
await Chats.delete_orphan_tags_for_user(tag_ids, user.id, db=db)
|
||||
await publish_event(
|
||||
request,
|
||||
EVENTS.CHAT_DELETED_ALL,
|
||||
@@ -1129,8 +1131,14 @@ async def archive_all_chats(
|
||||
async def unarchive_all_chats(
|
||||
request: Request, user=Depends(get_verified_user), db: AsyncSession = Depends(get_async_session)
|
||||
):
|
||||
tag_ids = {
|
||||
tag_id
|
||||
for chat in await Chats.get_archived_chats_by_user_id(user.id, db=db)
|
||||
for tag_id in chat.meta.get('tags', [])
|
||||
}
|
||||
result = await Chats.unarchive_all_chats_by_user_id(user.id, db=db)
|
||||
if result:
|
||||
await Tags.ensure_tags_exist(list(tag_ids), user.id, db=db)
|
||||
await publish_event(request, EVENTS.CHAT_UNARCHIVED, actor=user, subject_id=user.id, subject_type='user')
|
||||
return result
|
||||
|
||||
|
||||
Reference in New Issue
Block a user