feat(geofence): hear quakes, WFIGS incidents, and news pins

New hits carry a frozen evidence pack. adsb/ais/firms payloads stay
unchanged, and cameras are never passed to record_and_notify.
This commit is contained in:
Sirius DevOps 2026-11-14 00:40:10 -05:00
commit d878655617
7 changed files with 990 additions and 26 deletions

View file

@ -219,9 +219,32 @@ async def ingest_event(msg: dict):
await session.commit()
event_id = result.inserted_primary_key[0] # type: ignore[union-attr]
logger.info("Ingested event %s from source %s", event_id, msg.get("source_type"))
# Cameras are persisted as events only. Never a geofence hit.
if event_row["source_type"] == "earthquake":
await _notify_earthquake(event_row, event_id)
return event_id
async def _notify_earthquake(event_row: dict, event_id) -> None:
"""One hit per new quake. Dedup already dropped replays; skip if no point."""
lat, lon = event_row.get("location_lat"), event_row.get("location_lon")
if lat is None or lon is None:
return
try:
from geofence import earthquake_entity_id, record_and_notify
row = {**event_row, "id": str(event_id)}
await record_and_notify(
source_kind="earthquake",
entity_id=earthquake_entity_id(row),
lat=float(lat),
lon=float(lon),
payload={"title": event_row.get("title"), "url": event_row.get("url") or ""},
skip_existing=True,
)
except Exception:
logger.exception("earthquake geofence notify failed")
async def start_nats_consumer():
"""Start NATS JetStream consumer for OSINT events."""
nc = await nats.connect(NATS_URLS)