mirror of
https://github.com/mauriceboe/TREK.git
synced 2026-11-29 16:10:07 +00:00
feat(admin): let an operator switch the place index off
trek_places_enabled was read by six call paths — search, autocomplete, the POI pills, booking-import geocoding, the offline area and details resolution — and written by nothing. No admin route, no MCP tool, no switch anywhere in the UI, and the key is not in the settings allow-lists either, so the only way to set it was an INSERT against app_settings by hand on the server. That matters more than the four switches beside it, which trade away quota. This one decides whether every search and every keystroke in the place box leaves the instance at all. The flag reads fail-open, so an install that upgrades without visiting the admin panel starts sending them, which is the right default and exactly why the operator needs somewhere to say no. Adds the pair symmetrically to place-shadow from the same branch: getTrekPlaces /updateTrekPlaces on AddonsService, GET/PUT /api/admin/trek-places with an audit row, and a real switch on the card. The read stays fail-open so it keeps agreeing with MapsService.trekPlacesEnabled(), and a test pins that agreement across every stored value — if those two ever diverge the panel shows "off" while the queries keep leaving, which is worse than either default. The card said this itself: `available` was a display-only prop whose comment read "False until the client is wired to the service; the card then says so instead of offering a switch that would do nothing." It is wired now, so the prop is a switch. Its two badge strings had been shipped to all 23 locales and rendered nowhere; they make way for the switch label and a line naming what answers while the index is off.
This commit is contained in:
@@ -218,6 +218,28 @@ export class AddonsService {
|
||||
|
||||
updatePlacesEnrich(enabled: boolean) { return this.writeFlag('places_enrich_enabled', enabled); }
|
||||
|
||||
/**
|
||||
* The TREK place index, read fail-OPEN for the same reason enrichment is.
|
||||
*
|
||||
* This is the one switch on the card that is about egress rather than about
|
||||
* spending: with it on, every search and every keystroke in the place box
|
||||
* leaves the instance for places.liketrek.com. An operator who does not want
|
||||
* that needs somewhere to say so, and until this pair existed the key was
|
||||
* read by six call paths and written by nobody — the only way to turn the
|
||||
* index off was an INSERT against app_settings by hand.
|
||||
*
|
||||
* It has to agree with MapsService.trekPlacesEnabled(), which reads the same
|
||||
* key the same way. If the two ever disagree, the panel shows "off" while the
|
||||
* queries keep leaving, which is the worst of both.
|
||||
*/
|
||||
getTrekPlaces() {
|
||||
const row = this.db.prepare("SELECT value FROM app_settings WHERE key = 'trek_places_enabled'").get() as
|
||||
| { value: string }
|
||||
| undefined;
|
||||
return { enabled: row?.value !== 'false' };
|
||||
}
|
||||
updateTrekPlaces(enabled: boolean) { return this.writeFlag('trek_places_enabled', enabled); }
|
||||
|
||||
// ── Transit backend (#1699) ────────────────────────────────────────────────
|
||||
// Not a flag: two named backends, so it stores the name rather than a
|
||||
// boolean. The read/write pair lives in transit/transit-provider.ts because
|
||||
|
||||
@@ -253,6 +253,20 @@ export class AdminController {
|
||||
return result;
|
||||
}
|
||||
|
||||
// The one switch here that is about egress rather than about spending: with
|
||||
// the index on, every search and every keystroke in the place box leaves the
|
||||
// instance. Six call paths read the key; until this pair existed nothing
|
||||
// wrote it, so an operator who wanted it off had no way to say so.
|
||||
@Get('trek-places')
|
||||
getTrekPlaces() { return this.addons.getTrekPlaces(); }
|
||||
|
||||
@Put('trek-places')
|
||||
updateTrekPlaces(@CurrentUser() user: User, @Body() body: AdminFeatureToggleDto, @Req() req: Request) {
|
||||
const result = this.addons.updateTrekPlaces(body.enabled);
|
||||
this.audit.writeAudit({ userId: user.id, action: 'admin.trek_places', ip: getClientIp(req), details: { enabled: result.enabled } });
|
||||
return result;
|
||||
}
|
||||
|
||||
@Get('collab-features')
|
||||
getCollabFeatures() { return this.addons.getCollabFeatures(); }
|
||||
|
||||
|
||||
Reference in New Issue
Block a user