This commit is contained in:
2026-08-24 17:59:33 +03:00
parent 1fbe845b30
commit 65a2521156
5 changed files with 136 additions and 24 deletions

View File

@@ -5,7 +5,7 @@ from datetime import date
from time import perf_counter
from typing import Any, Callable
from fastapi import APIRouter, Depends, HTTPException, Query, Request
from fastapi import APIRouter, BackgroundTasks, Depends, HTTPException, Query, Request
from pydantic import BaseModel, ConfigDict, Field
from sqlalchemy import text
@@ -1149,6 +1149,7 @@ def create_hockey_router(
@router.post("/sessions")
async def open_session(
payload: SessionPayload,
background_tasks: BackgroundTasks,
user: HockeyUser = Depends(auth_dependency),
) -> dict[str, Any]:
try:
@@ -1169,7 +1170,18 @@ def create_hockey_router(
tournament_external_id=str(result.get("tournament_external_id") or ""),
device_id=vmix_device_id,
operator_session_token=str(result.get("token") or ""),
# BUILD109: selecting a match must not wait for a full
# Mapping push to vMix. The Agent receives match.assign
# immediately; Mapping starts only after the HTTP response.
wait_for_mapping=False,
)
assignment = result.get("agent_assignment") or {}
if assignment.get("delivered") and assignment.get("device_id"):
background_tasks.add_task(
agent_hub.apply_mapping_to_device,
str(assignment.get("device_id")),
reason="match_assigned",
)
except Exception as agent_error:
# The match/session must remain usable even when a browser
# carries a stale Agent id from another WFL account.