option to keep all activities private from strava zip, fix copy of register link
This commit is contained in:
@@ -786,7 +786,10 @@ async def strava_reset(request: Request) -> JSONResponse:
|
||||
|
||||
|
||||
@app.post("/api/upload/strava-zip")
|
||||
async def upload_strava_zip(file: UploadFile = File(...)) -> StreamingResponse:
|
||||
async def upload_strava_zip(
|
||||
file: UploadFile = File(...),
|
||||
private: str = Form(default="false"),
|
||||
) -> StreamingResponse:
|
||||
"""Accept a Strava bulk export ZIP and stream SSE progress while processing.
|
||||
|
||||
The ZIP is written to a temp file, processed activity-by-activity, then deleted.
|
||||
@@ -795,6 +798,8 @@ async def upload_strava_zip(file: UploadFile = File(...)) -> StreamingResponse:
|
||||
if not file.filename or not file.filename.lower().endswith(".zip"):
|
||||
raise HTTPException(400, "Please upload a .zip file")
|
||||
|
||||
privacy = "private" if private.lower() in ("true", "1", "yes") else "public"
|
||||
|
||||
dd = _get_data_dir()
|
||||
import tempfile
|
||||
tmp = tempfile.NamedTemporaryFile(suffix=".zip", delete=False, dir=dd)
|
||||
@@ -811,7 +816,7 @@ async def upload_strava_zip(file: UploadFile = File(...)) -> StreamingResponse:
|
||||
def event_stream():
|
||||
any_imported = False
|
||||
try:
|
||||
for event in strava_zip_iter(zip_path, dd):
|
||||
for event in strava_zip_iter(zip_path, dd, privacy=privacy):
|
||||
yield f"data: {json.dumps(event)}\n\n"
|
||||
if event.get("type") == "progress" and event.get("status") == "imported":
|
||||
any_imported = True
|
||||
|
||||
Reference in New Issue
Block a user