feat(flight-live): follow booked flights live from keyless ADS-B feeds

A new flight-live domain polls the open feeds adsb.lol and adsb.fi (no key,
no cost; adsb.fi only on self-hosted installs, its terms are non-commercial)
for every booked flight leg in its watch window, derives phase, take-off,
landing, delay and an arrival estimate, and pushes changes as flight:live.
GET /api/trips/:tripId/flights/live, the MCP tool get_trip_flight_status,
notifications for take-off, landing and delays, and the admin switch
flight_live_enabled (FLIGHT_LIVE_ENABLED wins) come with it.
This commit is contained in:
Maurice
2026-11-13 15:29:03 +01:00
parent 3365511b10
commit 154563f34d
143 changed files with 5048 additions and 14 deletions
@@ -93,6 +93,8 @@ export const APP_SETTINGS = {
// 'auto' (what every install had before Amap existed), 'google', 'amap' or
// 'openstreetmap'; the maps domain validates it (isPlacesProviderChoice).
places_provider: { schema: text, default: 'auto', adminForm: true, publicConfig: true, managedLocked: true },
// Live flight status from the keyless ADS-B feeds (flight-live). On by default; FLIGHT_LIVE_ENABLED wins over it.
flight_live_enabled: { schema: flag, default: 'true', env: (e) => e.integrations.flightLiveEnabled, adminForm: true },
// Read by name elsewhere.
oidc_issuer: { schema: text, default: null, env: (e) => e.oidc.issuer, publicConfig: true },
+37
View File
@@ -1,4 +1,6 @@
import { readEnv } from '../../app-config';
import { RuntimeEnvService } from '../app-config/runtime-env.service';
import { APP_SETTINGS, type AppSettingDef, type AppSettingKey } from './app-settings.registry';
import { byCodeUnit } from './compare';
import { SetMetadata } from '@nestjs/common';
@@ -144,6 +146,7 @@ export const MANAGED_CUSTOMER_KEYS = [
'dark_mode',
'default_currency',
'distance_unit',
'flight_live_enabled',
'map_provider',
'map_tile_url',
'mapbox_3d_enabled',
@@ -192,3 +195,37 @@ export function splitManagedKeys<T extends Record<string, unknown>>(
}
return { allowed, blocked: blocked.sort(byCodeUnit) };
}
/**
* Admin form switches an environment variable holds once it is set. The
* variable wins over the stored value anyway (resolveAppSetting), so the form
* shows the variable's value and a save leaves the stored one alone instead of
* pretending to change what still applies. SMTP keeps its old behaviour.
*/
const ENV_LOCKED_ADMIN_KEYS: readonly AppSettingKey[] = ['flight_live_enabled'];
/** The value the environment pins a switch to, or null while it is unset. */
function envValue(key: AppSettingKey): string | null {
return (APP_SETTINGS[key] as AppSettingDef).env?.(readEnv()) || null;
}
/** The env-held switches the write body sends, which the save skips and reports like the operator's keys. */
export function envLockedKeys(body: Record<string, unknown>): string[] {
return ENV_LOCKED_ADMIN_KEYS.filter((key) => body[key] !== undefined && envValue(key) !== null);
}
/**
* The admin form's values with every env-held switch set to the value that
* applies, and `env_override_<key>` beside it so the form can show the switch
* locked (the shape of `env_override_oidc_only` in the app config).
*/
export function withEnvLocks(values: Record<string, string>): Record<string, string> {
const out = { ...values };
for (const key of ENV_LOCKED_ADMIN_KEYS) {
const value = envValue(key);
if (value === null) continue;
out[key] = value;
out[`env_override_${key}`] = value;
}
return out;
}