feat: export all chats from db

admin only
This commit is contained in:
Timothy J. Baek 2024-02-04 01:07:18 -08:00
parent c4ca46637e
commit 7c2f297c84
4 changed files with 103 additions and 9 deletions

View file

@ -54,6 +54,25 @@ async def get_all_user_chats(user=Depends(get_current_user)):
]
############################
# GetAllChatsInDB
############################
@router.get("/all/db", response_model=List[ChatResponse])
async def get_all_user_chats_in_db(user=Depends(get_current_user)):
if user.role == "admin":
return [
ChatResponse(**{**chat.model_dump(), "chat": json.loads(chat.chat)})
for chat in Chats.get_all_chats()
]
else:
raise HTTPException(
status_code=status.HTTP_403_FORBIDDEN,
detail=ERROR_MESSAGES.ACCESS_PROHIBITED,
)
############################
# CreateNewChat
############################