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:
Sirius DevOps 2026-08-28 23:28:28 -04:00
commit 20a266563c
4 changed files with 63 additions and 23 deletions

View file

@ -610,8 +610,8 @@ def test_fetch_planespotters_photo_hex_builds_url_and_normalizes(monkeypatch):
seen = []
async def fake_get(url, params=None):
seen.append(url)
async def fake_get(url, params=None, headers=None):
seen.append((url, (headers or {}).get("User-Agent", "")))
return {"photos": [{
"id": "1", "thumbnail": {"src": "https://t.plnspttrs.net/a_t.jpg"},
"thumbnail_large": {"src": "https://t.plnspttrs.net/a_280.jpg"},
@ -622,7 +622,8 @@ def test_fetch_planespotters_photo_hex_builds_url_and_normalizes(monkeypatch):
_cache.clear()
out = asyncio.run(fetch_planespotters_photo(hex_code="e8027e"))
assert out["src"] == "https://t.plnspttrs.net/a_280.jpg"
assert seen == ["https://api.planespotters.net/pub/photos/hex/e8027e"]
assert seen[0][0] == "https://api.planespotters.net/pub/photos/hex/e8027e"
assert "@" in seen[0][1] or "http" in seen[0][1]
def test_fetch_planespotters_photo_reg_fallback_and_no_result(monkeypatch):
@ -632,7 +633,7 @@ def test_fetch_planespotters_photo_reg_fallback_and_no_result(monkeypatch):
seen = []
async def fake_get(url, params=None):
async def fake_get(url, params=None, headers=None):
seen.append(url)
return {"photos": []}
@ -642,3 +643,12 @@ def test_fetch_planespotters_photo_reg_fallback_and_no_result(monkeypatch):
assert seen == ["https://api.planespotters.net/pub/photos/reg/D-ABCD"]
# no hex and no reg → no upstream call at all
assert asyncio.run(fetch_planespotters_photo()) is None
def test_planespotters_headers_add_contact_when_ua_is_generic(monkeypatch):
import live_layers
monkeypatch.setattr(live_layers, "OSINT_USER_AGENT", "osint-dashboard/1.0 (self-hosted)")
ua = live_layers._planespotters_headers()["User-Agent"]
assert "osint-dashboard" in ua
assert "@" in ua