Add onsaling + better documentation.
This commit is contained in:
+12
-4
@@ -1,7 +1,7 @@
|
||||
import os
|
||||
|
||||
from dotenv import load_dotenv
|
||||
from fastapi import FastAPI, Depends, HTTPException, status
|
||||
from fastapi import Depends, FastAPI, HTTPException, status
|
||||
from fastapi.security import APIKeyHeader
|
||||
|
||||
import models
|
||||
@@ -12,7 +12,7 @@ load_dotenv()
|
||||
TARGET = os.getenv("TARGET_ID")
|
||||
VALID_API_KEY = os.getenv("VALID_API_KEY")
|
||||
|
||||
if not TARGET:
|
||||
if TARGET is None:
|
||||
raise EnvironmentError("TARGET_ID is missing from environment.")
|
||||
if not VALID_API_KEY:
|
||||
raise EnvironmentError("VALID_API_KEY is missing from environment.")
|
||||
@@ -25,8 +25,7 @@ api_key_header = APIKeyHeader(name="x-api-key")
|
||||
async def verify_api_key(api_key: str = Depends(api_key_header)):
|
||||
if api_key != VALID_API_KEY:
|
||||
raise HTTPException(
|
||||
status_code=status.HTTP_403_FORBIDDEN,
|
||||
detail="Invalid API key"
|
||||
status_code=status.HTTP_403_FORBIDDEN, detail="Invalid API key"
|
||||
)
|
||||
return api_key
|
||||
|
||||
@@ -56,4 +55,13 @@ async def reupload_asset(asset_id: int, _: str = Depends(verify_api_key)):
|
||||
asset.asset_type,
|
||||
models.RbxCreator(int(TARGET), "Upload_Group", "Group"),
|
||||
)
|
||||
new_asset_id = uploaded.get("asset_id")
|
||||
if new_asset_id:
|
||||
onsale = await roblox_service.onsale_asset(
|
||||
new_asset_id,
|
||||
asset.name,
|
||||
asset.description,
|
||||
int(TARGET),
|
||||
)
|
||||
return {"uploaded": uploaded}
|
||||
return uploaded
|
||||
|
||||
Reference in New Issue
Block a user