fix(aircraft): show planespotters photo in overlay popup
Planespotters 403s server clients whose User-Agent has no contact email; compose default UA lacked one. Leaflet popup.update() also re-ran the bindPopup factory and wiped the thumbnail after load. - Send a contact UA on planespotters lookups; align compose default. - Resize the popup without re-rendering content. - Keep hex/src on live firefighter upserts so they get a photo too.
This commit is contained in:
parent
bb849515fb
commit
20a266563c
4 changed files with 63 additions and 23 deletions
|
|
@ -751,6 +751,18 @@ def _headers() -> dict[str, str]:
|
|||
return {"User-Agent": OSINT_USER_AGENT, "Accept": "application/json"}
|
||||
|
||||
|
||||
def _planespotters_headers() -> dict[str, str]:
|
||||
"""Planespotters 403s server clients whose UA has no contact URL/email."""
|
||||
ua = (OSINT_USER_AGENT or "").strip()
|
||||
if ua and ("@" in ua or "http://" in ua.lower() or "https://" in ua.lower()):
|
||||
return {"User-Agent": ua, "Accept": "application/json"}
|
||||
base = ua or "osint-dashboard/1.0"
|
||||
return {
|
||||
"User-Agent": f"{base} ([email protected])",
|
||||
"Accept": "application/json",
|
||||
}
|
||||
|
||||
|
||||
async def _lock_for(key: str) -> asyncio.Lock:
|
||||
async with _key_locks_guard:
|
||||
lock = _key_locks.get(key)
|
||||
|
|
@ -794,15 +806,17 @@ async def close_http() -> None:
|
|||
_http = None
|
||||
|
||||
|
||||
async def _get_json(url: str, params: dict | None = None) -> Any:
|
||||
async def _get_json(
|
||||
url: str, params: dict | None = None, headers: dict | None = None,
|
||||
) -> Any:
|
||||
if _http is None:
|
||||
async with httpx.AsyncClient(
|
||||
timeout=_HTTP_TIMEOUT, follow_redirects=True, headers=_headers(),
|
||||
) as client:
|
||||
resp = await client.get(url, params=params)
|
||||
resp = await client.get(url, params=params, headers=headers)
|
||||
resp.raise_for_status()
|
||||
return resp.json()
|
||||
resp = await _http.get(url, params=params)
|
||||
resp = await _http.get(url, params=params, headers=headers)
|
||||
resp.raise_for_status()
|
||||
return resp.json()
|
||||
|
||||
|
|
@ -851,7 +865,7 @@ async def fetch_planespotters_photo(
|
|||
return None
|
||||
|
||||
async def _load() -> dict | None:
|
||||
data = await _get_json(url)
|
||||
data = await _get_json(url, headers=_planespotters_headers())
|
||||
photos = data.get("photos") or []
|
||||
return _normalize_planespotter_photo(photos[0]) if photos else None
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue