feat(ui): add 'Unshare All Shared Chats' button to Shared Chats modal (#25848)
This commit is contained in:
5 files changed
+114
-3
No files matched your search
@@ -201,5 +201,15 @@ class SharedChatsTable:
|
||||
except Exception:
|
||||
return False
|
||||
|
||||
async def delete_all_by_user_id(self, user_id: str, db: Optional[AsyncSession] = None) -> bool:
|
||||
"""Delete all shared chats created by a user."""
|
||||
try:
|
||||
async with get_async_db_context(db) as db:
|
||||
await db.execute(delete(SharedChat).filter_by(user_id=user_id))
|
||||
await db.commit()
|
||||
return True
|
||||
except Exception:
|
||||
return False
|
||||
|
||||
|
||||
SharedChats = SharedChatsTable()
|
||||
@@ -853,10 +853,27 @@ async def unarchive_all_chats(user=Depends(get_verified_user), db: AsyncSession
|
||||
|
||||
|
||||
############################
|
||||
# GetSharedChats
|
||||
# UnshareAllChats
|
||||
############################
|
||||
|
||||
|
||||
@router.delete('/share/all', response_model=bool)
|
||||
async def unshare_all_chats(user=Depends(get_verified_user), db: AsyncSession = Depends(get_async_session)):
|
||||
# Collect chat_ids that have shares so we can clear share_id and access grants
|
||||
shared_list = await SharedChats.get_by_user_id(user.id, db=db)
|
||||
chat_ids = [s.chat_id for s in shared_list]
|
||||
|
||||
# Delete all shared_chat rows for this user
|
||||
result = await SharedChats.delete_all_by_user_id(user.id, db=db)
|
||||
|
||||
# Clear share_id on the original chats and remove access grants
|
||||
for chat_id in chat_ids:
|
||||
await Chats.update_chat_share_id_by_id(chat_id, None, db=db)
|
||||
await AccessGrants.set_access_grants('shared_chat', chat_id, [], db=db)
|
||||
|
||||
return result
|
||||
|
||||
|
||||
@router.get('/shared', response_model=list[SharedChatResponse])
|
||||
async def get_shared_session_user_chat_list(
|
||||
page: int | None = None,
|
||||
|
||||
Reference in new issue
Block a user