Added getting the last save
This commit is contained in:
parent
daa3b0ca73
commit
ce768d895d
@ -1,7 +1,7 @@
|
||||
from datetime import datetime
|
||||
from urllib.parse import quote_plus
|
||||
from os import remove
|
||||
from typing import Dict, List, Union
|
||||
from typing import Dict, List, Literal, Union
|
||||
from xmltodict import parse
|
||||
from models.saves import StardewSave
|
||||
from modules.app import app, get_api_key, user_by_key
|
||||
@ -72,8 +72,8 @@ async def saves_get_by_id(id: int, device: Union[str, None] = None, version: Uni
|
||||
return UJSONResponse(output)
|
||||
|
||||
|
||||
@app.get("/saves/{id}/{save_date}", response_class=UJSONResponse, response_model=List[StardewSave], description="Get game saves by name")
|
||||
async def saves_get_by_both_ids(id: int, save_date: int, device: Union[str, None] = None, apikey: APIKey = Depends(get_api_key)):
|
||||
@app.get("/saves/{id}/{save_date}", response_class=UJSONResponse, response_model=List[StardewSave], description="Get game saves by id and upload date")
|
||||
async def saves_get_by_both_ids(id: int, save_date: Union[int, Literal["latest"]], device: Union[str, None] = None, apikey: APIKey = Depends(get_api_key)):
|
||||
|
||||
query = {"user": user_by_key(apikey), "id": id, "date": save_date}
|
||||
|
||||
@ -90,7 +90,7 @@ async def saves_get_by_both_ids(id: int, save_date: int, device: Union[str, None
|
||||
raise HTTPException(HTTP_404_NOT_FOUND, detail="Could not find save with such id.")
|
||||
|
||||
|
||||
@app.delete("/saves/{id}", description="Get game saves by name")
|
||||
@app.delete("/saves/{id}", description="Delete game saves by id")
|
||||
async def saves_delete_by_id(id: int, apikey: APIKey = Depends(get_api_key)):
|
||||
user = user_by_key(apikey)
|
||||
if col_saves.count_documents({"user": user, "id": id}) > 0:
|
||||
@ -103,7 +103,7 @@ async def saves_delete_by_id(id: int, apikey: APIKey = Depends(get_api_key)):
|
||||
raise HTTPException(HTTP_404_NOT_FOUND, detail="Could not find save with such id.")
|
||||
|
||||
|
||||
@app.delete("/saves/{id}/{save_date}", response_class=UJSONResponse, description="Get game saves by name")
|
||||
@app.delete("/saves/{id}/{save_date}", response_class=UJSONResponse, description="Delete game saves by id and upload date")
|
||||
async def saves_delete_by_both_ids(id: int, save_date: int, apikey: APIKey = Depends(get_api_key)):
|
||||
saves_entry = col_saves.find_one_and_delete({"id": id, "date": save_date})
|
||||
if saves_entry is not None:
|
||||
@ -113,7 +113,7 @@ async def saves_delete_by_both_ids(id: int, save_date: int, apikey: APIKey = Dep
|
||||
raise HTTPException(HTTP_404_NOT_FOUND, detail="Could not find save with such id.")
|
||||
|
||||
|
||||
@app.get("/saves/{id}/{save_date}/download", response_class=FileResponse, description="Get game save as .svsave file by its id and save date")
|
||||
@app.get("/saves/{id}/{save_date}/download", response_class=FileResponse, description="Get game save as .svsave file by its id and upload date")
|
||||
async def saves_download(id: int, save_date: int, device: Union[str, None] = None, apikey: APIKey = Depends(get_api_key)):
|
||||
saves_entry = col_saves.find_one({"user": user_by_key(apikey), "id": id, "date": save_date}) if device is None else col_saves.find_one({"user": user_by_key(apikey), "id": id, "device": device, "date": save_date})
|
||||
if saves_entry is not None: # type: ignore
|
||||
|
Loading…
Reference in New Issue
Block a user