From 0907c32e1085ddab73244c5ae26fe13e4b1c62c8 Mon Sep 17 00:00:00 2001 From: "Timothy J. Baek" Date: Tue, 1 Oct 2024 09:51:58 -0700 Subject: [PATCH] refac --- backend/open_webui/apps/webui/routers/chats.py | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/backend/open_webui/apps/webui/routers/chats.py b/backend/open_webui/apps/webui/routers/chats.py index 21f95d9fe..ca7e95baf 100644 --- a/backend/open_webui/apps/webui/routers/chats.py +++ b/backend/open_webui/apps/webui/routers/chats.py @@ -52,10 +52,9 @@ async def get_session_user_chat_list( @router.delete("/", response_model=bool) async def delete_all_user_chats(request: Request, user=Depends(get_verified_user)): - if ( - user.role == "user" - and not request.app.state.config.USER_PERMISSIONS["chat"]["deletion"] - ): + if user.role == "user" and not request.app.state.config.USER_PERMISSIONS.get( + "chat", {} + ).get("deletion", {}): raise HTTPException( status_code=status.HTTP_401_UNAUTHORIZED, detail=ERROR_MESSAGES.ACCESS_PROHIBITED, @@ -292,7 +291,9 @@ async def delete_chat_by_id(request: Request, id: str, user=Depends(get_verified result = Chats.delete_chat_by_id(id) return result else: - if not request.app.state.config.USER_PERMISSIONS["chat"]["deletion"]: + if not request.app.state.config.USER_PERMISSIONS.get("chat", {}).get( + "deletion", {} + ): raise HTTPException( status_code=status.HTTP_401_UNAUTHORIZED, detail=ERROR_MESSAGES.ACCESS_PROHIBITED,