Added search by device

This commit is contained in:
Profitroll 2023-01-18 14:27:58 +01:00
parent e9e9e3784a
commit 1beca94cc0

View File

@ -46,9 +46,10 @@ def zipfiles(filenames, save_name: str) -> Response:
@app.get("/saves", response_class=UJSONResponse, response_model=Dict[str, StardewSave], description="Get all available game saves") @app.get("/saves", response_class=UJSONResponse, response_model=Dict[str, StardewSave], description="Get all available game saves")
async def saves_get(apikey: APIKey = Depends(get_api_key)): async def saves_get(device: Union[str, None] = None, apikey: APIKey = Depends(get_api_key)):
saves_entries = list(col_saves.find({"user": user_by_key(apikey)})) user = user_by_key(apikey)
saves_entries = list(col_saves.find({"user": user})) if device is None else list(col_saves.find({"user": user_by_key(apikey), "user": user}))
if len(saves_entries) == 0: if len(saves_entries) == 0:
raise HTTPException(HTTP_404_NOT_FOUND, detail="Could not find any saves.") raise HTTPException(HTTP_404_NOT_FOUND, detail="Could not find any saves.")