fix(feeds): keep a staged booking out of the public feed and the shared trip

The ICS feed is public with a token that never expires and prints the
confirmation number into the DESCRIPTION, and the shared-trip payload does a
SELECT * over reservations with share_bookings on by default. Neither filters
anything, so whatever lands on a trip is published the moment it is written.
That is fine while a person types every booking in, and it stops being fine as
soon as something writes on their behalf.

reservations.ingest_state is that gate. It defaults to live, SQLite backfills
every existing row on the ALTER, and no current writer names the column, so
every booking visible today stays visible. Nothing writes staged yet.

The predicate takes its table alias because share.service.ts queried
reservations without one. A stay is withheld only when bookings point at it and
all of them are staged: a hand-added hotel has no booking at all and has to keep
showing up.
This commit is contained in:
Maurice
2026-08-28 13:23:07 +02:00
committed by Maurice
parent 8641788de0
commit 15588d20c9
12 changed files with 389 additions and 8 deletions
+18
View File
@@ -4136,6 +4136,24 @@ function runMigrations(db: Database.Database): void {
console.warn('[migrations] Non-fatal migration step failed:', err);
}
},
// Reservations an automated ingest parked for review are 'staged' and stay
// out of the two anonymous exports (ICS feed, shared trip) until a person
// confirms them. Nothing writes 'staged' yet; this is the gate the mail
// ingest writes through.
//
// 'live' as the default is what keeps this from being a breaking change:
// SQLite fills every existing row on the ALTER, and no current writer names
// the column, so every booking that is visible today stays visible.
// Appended LAST, the array is index-addressed against schema_version.
() => {
const hasColumn = db
.prepare("SELECT 1 FROM pragma_table_info('reservations') WHERE name = 'ingest_state'")
.get();
if (!hasColumn) {
db.exec("ALTER TABLE reservations ADD COLUMN ingest_state TEXT NOT NULL DEFAULT 'live'");
}
},
];
if (currentVersion < migrations.length) {