mirror of
https://github.com/open-webui/open-webui
synced 2025-05-23 14:24:22 +00:00
refac
This commit is contained in:
parent
7b9b29253f
commit
0907c32e10
@ -52,10 +52,9 @@ async def get_session_user_chat_list(
|
|||||||
|
|
||||||
@router.delete("/", response_model=bool)
|
@router.delete("/", response_model=bool)
|
||||||
async def delete_all_user_chats(request: Request, user=Depends(get_verified_user)):
|
async def delete_all_user_chats(request: Request, user=Depends(get_verified_user)):
|
||||||
if (
|
if user.role == "user" and not request.app.state.config.USER_PERMISSIONS.get(
|
||||||
user.role == "user"
|
"chat", {}
|
||||||
and not request.app.state.config.USER_PERMISSIONS["chat"]["deletion"]
|
).get("deletion", {}):
|
||||||
):
|
|
||||||
raise HTTPException(
|
raise HTTPException(
|
||||||
status_code=status.HTTP_401_UNAUTHORIZED,
|
status_code=status.HTTP_401_UNAUTHORIZED,
|
||||||
detail=ERROR_MESSAGES.ACCESS_PROHIBITED,
|
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)
|
result = Chats.delete_chat_by_id(id)
|
||||||
return result
|
return result
|
||||||
else:
|
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(
|
raise HTTPException(
|
||||||
status_code=status.HTTP_401_UNAUTHORIZED,
|
status_code=status.HTTP_401_UNAUTHORIZED,
|
||||||
detail=ERROR_MESSAGES.ACCESS_PROHIBITED,
|
detail=ERROR_MESSAGES.ACCESS_PROHIBITED,
|
||||||
|
Loading…
Reference in New Issue
Block a user