Commit Graph

2319 Commits

Author SHA1 Message Date
Maurice a0c41bce0a fix(notifications): list the wanderer hints for users whose trip switched Tours on
The user's matrix decides that row by the same per-user Tours rule the wanderer watch sends by, so a user who gets the hints can see and switch them.
2026-11-23 15:45:25 +01:00
Maurice 1a6639eb74 fix(trips): end a plugin-added member's MCP sessions where the trip opened an addon
trips.addMember now calls reattachJoinedMember like the REST, MCP and invite joins, so the new member's session lists the trip's addon tools.
2026-11-23 15:45:25 +01:00
Maurice 807c6a16b4 fix(plugins): handle a failed addon read while an earlier trip event still waits
The addon read of a queued plugin event now settles to off on its own, so a rejection that comes before the earlier event's turn can no longer go unhandled and stop the server.
2026-11-23 15:45:25 +01:00
Maurice 5d7d6072f7 fix(mail-ingest): refresh MCP sessions when an admin switches the mail import
The mail import tools are listed only while the import is on, so a save that changes mail_ingest_enabled now ends the live MCP sessions, as the addon switches do.
2026-11-23 15:45:25 +01:00
Maurice 4cd3f3d650 fix(files): serve a plugin the files a trip keeps while Documents is off
The plugin file surface follows the REST rule: the list and reads keep booking, place, expense, note and message files, a write on a loose file goes through when it attaches it, and uploads and deletes stay open.
2026-11-23 15:45:25 +01:00
Maurice a0d66eb898 fix(files): attach a loose file while the trip has Documents off
update and link go through when the request itself attaches the file to a booking, place, stop or expense, on REST and MCP alike, and upload_trip_file takes budget_item_id like the REST upload.
2026-11-23 15:45:24 +01:00
Maurice 8a2045c619 fix(mail-ingest): attach a booking's documents while the trip has Documents off
A booking's files belong to the booking, so the mail's documents now reach it whatever the Documents switch says; a mail filed without a booking still needs Documents.
2026-11-23 15:17:02 +01:00
Maurice 34d5fba437 fix(plugins): deliver a trip's core events to plugins in emission order
The addon check in front of the event sink made each family event wait for
its own read, so on Postgres a later snapshot could overtake an earlier one,
and a trip event could arrive before the budget event emitted ahead of it.
The reads still run side by side, but a trip's events now leave in order.
2026-11-23 15:15:37 +01:00
Maurice 8b9de04960 fix(wanderer): offer the connection and run the watch where a trip switched Tours on
With Tours off for the instance, a trip that switched it on opened the wanderer
import, but Settings hid the connection and the watch cron never ran. The addon
feed now tells each user whether wanderer applies to them, and the watch looks
for every user who has Tours on somewhere; the others only take their turn.
2026-11-23 15:15:36 +01:00
Maurice c289541c43 fix(notifications): list the paddle region request for admins while any trip has Tours on
The admin matrix decided a trip addon by the admin's own trips, so with Tours
off for the instance and on for a member's trip the paddle region request still
reached admins but had no row to switch it. Admin-scoped rows now follow the
addon being on for the instance or any trip.
2026-11-23 15:15:36 +01:00
Maurice 146f46c5e3 fix(addons): give a member who joins a trip with an opened addon a new MCP session
A trip that switched on an addon the instance has off ended the MCP sessions
of the members it had then, but somebody added later, or joining through the
invite link, kept a session without that addon's tools. Joining now ends it too.
2026-11-23 15:15:36 +01:00
Maurice 8709f67ff4 fix(trip-members): leave expenses out of a guest deletion while Costs is off
Deleting a guest re-sent every expense that named them as budget:updated,
even on a trip with Costs switched off, so each member's offline cache took
rows the bundle keeps out. The re-split expenses now go out only while the
trip has Costs on.
2026-11-23 15:15:36 +01:00
Maurice 48e54d5a62 fix(files): keep booking, place and expense files reachable with Documents off
The Documents addon now gates only the file manager: the list leaves out loose
files, and the trash, starring and loose files answer 404, while uploads, deletes
and every file a booking, place, expense, note or message carries stay reachable
over REST, the download route, MCP and the offline bundle.
2026-11-23 15:15:36 +01:00
Maurice 8fb720ea49 fix(mcp): validate a tool or prompt field again once NUL stripping changed it
The SDK validates the arguments before the input mapper drops NUL characters, so a field the mapper changes is now checked against its own schema again and a name of nothing but NUL is refused over MCP as it is over REST.
2026-11-23 15:11:39 +01:00
Maurice 1fb1b102e8 fix(dawarich): name an unnamed stay once Dawarich has geocoded its points
A stay stored as 'Unnamed stay' because none of its points was geocoded yet is now read again on the next sync, so a slow background geocoder or a stay from before the upgrade gets its town once Dawarich knows it.
2026-11-23 15:11:39 +01:00
Maurice a604f84899 fix(memories): send share link viewers the Immich preview instead of the original file
A public view of an Immich image now asks for the preview rendition, which Immich re-encodes without the stored metadata, so photo locations no longer go out with share links; owners still get the fullsize original.
2026-11-23 15:11:39 +01:00
Maurice e7e3592d97 fix(flight-live): tell a delay only to the bookings it is late for
Bookings that share one flight state can hold different scheduled times, so the delay notice now goes only to the legs whose own departure is at least fifteen minutes late instead of telling the others it is delayed by 0 minutes.
2026-11-23 15:11:39 +01:00
Maurice 8e51410251 fix(flight-live): do not read an earlier sector's aircraft as this flight having departed
Before the scheduled departure, an aircraft in the air that is no nearer the destination than the origin is now stays unpicked, so booking only the later sector of a through flight no longer sends the departure notice hours early.
2026-11-23 15:11:39 +01:00
Maurice 22c3381044 fix(tags): keep a trip's tags when the member who created them deletes their account
The trip tags a deleted user created now pass to each trip's owner before the user row goes, so the tag and its place assignments no longer cascade away for everyone else on the trip.
2026-11-23 15:11:38 +01:00
Maurice 9d4e52ddfc perf(db): let Postgres serve ORDER BY id from the primary key
A Kysely ORDER BY on the id of a table the statement reads in its FROM no longer gets SQLite's NULL position, which no primary key row needs and which kept Postgres from reading paged latest-first lists such as the audit log off the index.
2026-11-23 15:11:34 +01:00
Maurice 52a6fbbc92 fix(scripts): read the server's .env in the admin reset and the key rotation
Both scripts now load server/.env as the server does, so an install whose TREK_DB_URL lives there resets the admin and rotates the key in its Postgres database instead of in a SQLite file left behind by the move.
2026-11-23 15:11:33 +01:00
Maurice de1c3b8ea6 fix(scripts): rotate the SQLite file TREK_DB_FILE names
The key rotation now opens the database the server runs on when TREK_DB_FILE is set, writes the new key to the key file the server reads, and refuses DB_PATH and TREK_DB_FILE naming different files.
2026-11-23 15:11:33 +01:00
Maurice 60885627b1 fix(scripts): rotate the wanderer token with the encryption key
The key rotation now re-encrypts wanderer_connections.token, so a wanderer connection keeps working after the key changes instead of calling out without its token.
2026-11-23 15:11:33 +01:00
Maurice 9c454a04e1 fix(db): keep plugin index names when moving plugin data to Postgres
The move now creates each index a plugin named under that name, so a later plugin migration that drops or alters it by name finds it on a moved install as on a fresh one.
2026-11-23 15:11:33 +01:00
Maurice 6a6c403860 fix(db): keep booking to stay links of old installs when moving to Postgres
An install from before April 2026 stores reservations.accommodation_id as an INTEGER, so the move now writes such a stay id as the '<id>.0' text TREK compares it as, instead of '14', which no longer matched the stay on Postgres.
2026-11-23 15:11:33 +01:00
Maurice e51902a03b fix(reservations): drop a stay id from another trip when a booking is created
Create now checks that the linked stay belongs to the trip, as update already does, instead of storing a link to a stay that does not exist there.
2026-11-23 15:11:33 +01:00
Maurice 3a2645a3e4 fix(db): match a booking to its stay on Postgres without failing on odd ids
The Postgres stay match now casts the leading digits of the stored text as bigint, the way SQLite reads it, so a non-numeric or oversized accommodation_id no longer fails the calendar, share and stay reads for every trip.
2026-11-23 15:11:32 +01:00
Maurice bf8677a28c fix(backup): name the client tool when pg_restore cannot read a Postgres dump
A missing pg_restore, or one older than the pg_dump that wrote the archive, was reported as an invalid dump. The refusal now says which tool to install or point TREK_DB_PG_BIN_DIR at.
2026-11-23 15:11:32 +01:00
Maurice 89da19e535 fix(backup): refuse a Postgres restore the role or tools cannot run before anything is copied
The admin restore now answers a privileged role, old client tools or an unreachable server with a 400 naming the reason, before it keeps a pre-restore dump. RESTORE_FROM_BACKUP checks the same before it unpacks the archive, and removes the unpacked copy when the load fails.
2026-11-23 15:11:32 +01:00
Maurice e630e92183 fix(backup): clear a Postgres schema holding views or functions over TREK's tables
A table dropped with CASCADE takes its views and functions along, and the clear then rendered their stale oids as bare numbers and failed the restore. Rows whose object is already gone are now skipped.
2026-11-23 15:11:32 +01:00
Maurice bb2b4a1f5a fix(backup): restore Postgres backups into PostgreSQL 14, 15 and 16
pg_restore 17 and later write SET transaction_timeout at the top of every script, which older servers refuse under ON_ERROR_STOP. The restore now leaves settings the target server does not know out of the script while it streams.
2026-11-23 15:11:32 +01:00
Maurice 626e19c534 fix(mail-ingest): keep bookings the data names that the AI left out
When the AI returned fewer bookings than the machine-readable data, the others were dropped without an entry.
2026-11-23 15:11:31 +01:00
Maurice 8f5988ee33 fix(mail-ingest): match each AI leg to the data leg it agrees with
Under one booking reference every leg after the first was compared with the first and went to the inbox as a disagreement.
2026-11-23 15:11:31 +01:00
Maurice 4cef885e12 fix(mail-ingest): never queue a mail again for a failure after its commit
An error in the announcements, documents or notices after a mail was written sent it back to the queue, which duplicated its entries or marked it failed.
2026-11-23 15:11:31 +01:00
Maurice 303d161ecf fix(mail-ingest): keep a booking that fails the item shape in the inbox
Such a booking made the whole mail fail and retry instead of waiting to be filled in by hand. A reference read as a number is now read as its text.
2026-11-23 15:11:31 +01:00
Maurice eaa557343e fix(mail-ingest): compare look-alike bookings at their wall time on any server zone
The window around a booking's start went through the host time zone, so on a server outside UTC it missed a booking at the same local time and added it twice.
2026-11-23 15:11:31 +01:00
Maurice dea903f011 fix(booking-import): treat a booking a forwarded mail added as already imported
The file and assistant import only looked for bookings the file import wrote, so the same booking arrived twice when it had come in by mail first.
2026-11-23 15:11:30 +01:00
Maurice 91edf0c565 fix(mail-ingest): announce a place a mail created with its whole row
The open planners of the trip received only the new place's id and kept a nameless place without coordinates until a reload. The broadcast now carries the row the place routes send.
2026-11-23 15:11:30 +01:00
Maurice 403b7d2f93 fix(mail-ingest): make the own address once when two views ask for it together
The first look at the settings made the address outside a transaction and always revoked the live one, so two requests at once could leave a view showing a revoked address. It is now checked and made in one transaction and never replaces an address it finds.
2026-11-23 15:11:30 +01:00
Maurice 5d4cfec3b6 fix(mail-ingest): list the mail import tools only while the import is on
Every mail tool answered 'Mail import is not available' on installs that never switched the import on, which is the default, so they are now gated like the addon tools.
2026-11-23 15:11:30 +01:00
Maurice b9608bf684 fix(mail-ingest): keep the webhook open for real deliveries while bodies trickle in
The webhook now limits the memory the bodies being read hold instead of the number of open requests, and gives up on a body still arriving after a minute, so a few slow requests no longer turn every delivery away.
2026-11-23 15:11:29 +01:00
Maurice 3b65da7626 fix(mail-ingest): read transfer bookings instead of filing them as forwarding confirmations
A forwarding subject now counts only from Gmail or Microsoft or together with a code in the body, so 'Votre transfert est confirmé' is read as a booking. The subject and From header are also matched in linear time.
2026-11-23 15:11:29 +01:00
Maurice 327539df14 fix(mail-ingest): read forwarded attributions and HTML tags in linear time
A long line of reply verbs, or HTML with line break, script or style tags that never close, made the mail walk backtrack once per word and block the server. Attribution lines past 500 characters are no longer tested.
2026-11-23 15:11:29 +01:00
Maurice c0f6551cf4 test(server): send the API key requests without awaiting in a loop
Server lint counted one no-await-in-loop warning over the tests baseline, from the loop in the new API key test.
2026-11-22 18:24:15 +01:00
Maurice 1fdf74e7f2 fix(auth): mark an address the account moved before an admin saved it
Both backfills of email_self_asserted skip any account with an
admin.user_update row naming email. The edit dialog sends the email on every
save, so a role change made long after an account moved its own address kept
it at 0, and a verified SSO sign-in with that address still linked into it.

A new migration reads the address each admin save found (targetUser): an
account is marked when every save already found its current address, or when
the last save that found another one sent no email. A save that may have typed
the current address in still leaves the account alone, since the audit rows
cannot tell it from a change the account made itself before 5.0.0. Only rows
still at 0 are touched and nothing is cleared.
2026-11-22 18:15:51 +01:00
Maurice c7de823c78 fix(auth): renew a session cookie only after it verifies on its own
SessionRenewalInterceptor took req.user as proof that the trek_session cookie
had been verified. On a route with its own guard chain that does not hold:
ApiTokenGuard authenticates a public API key and sets req.user, and the cookie
sent beside it is never checked. Past half its lifetime such a cookie was
decoded without its signature and renewed, so a holder of a read-only key
could come away with a signed session of the key's owner.

The interceptor now runs the cookie through the guards' own check (signature,
expiry, password version, active session) before it renews, requires it to
name the request's user, and renews nothing on a request a public API key
authenticated.
2026-11-22 18:15:51 +01:00
Maurice 7006891ce0 style(server): format the legs-only seat test
Server lint was red: lint:format found the new update_transport cases in tools-transports.test.ts unformatted.
2026-11-21 15:37:00 +01:00
Maurice 4d01439c75 test(server): type the created transport in the legs-only seat test
Server lint was red: the new MCP test cast its result to any, one no-explicit-any warning over the tests baseline.
2026-11-21 15:29:53 +01:00
Maurice adb6a2c80d fix(planner): show each leg's own seat on a flight with a stop
A flight with a stop saves a seat per leg, but every view read the
booking's flat seat, which mirrors the first leg's. A seat booked only on
the second leg showed nowhere, and one on the first leg showed on both.
#2701 had fixed this for trains only.

- getFlightLegs reads each leg's seat. The first leg falls back to the flat
  seat, as the booking form does, so older bookings keep theirs.
- bookingSeats lists the seat of every leg that has one with its route.
  The detail views (the phone's transport sheet, the booking detail) show
  each leg's seat under its route ("Seat IST → JFK"), and a leg opened
  from its row shows its own. The cards and field grids (bookings list,
  the phone's Bookings and Transports tabs, the day plan's transport
  detail) hold every seat in one Seat cell, so a card cutting its grid
  short no longer drops the second leg's.
- The day plan's flight leg rows carry their seat, and the PDF prints a
  flight's seat, direct or per leg.
- The watch and the Wallet pass name every leg's seat of the booking.
- A legs-only MCP update sets the flat seat, airline and flight number
  (train number and platform) again from the new first leg, so a seat
  taken off the first leg does not live on in the flat seat. A flat value
  the stored first leg never had stays.

Closes #3158
2026-11-21 15:24:52 +01:00
Maurice 1824cc77ec fix(ci): bring the per-trip addon tests and ratchets in step
The second run of #3157 was red in six jobs:
- Server types: ReminderJobsService takes AddonsService now; RJOB-007 built
  it with five arguments.
- Server tests 2/10: the doc-sync job tests stubbed AddonsService without
  isEnabledForTrip, which the sync asks per trip now.
- Client tests 4/10: toursPermissions mocked useAuthStore as a bare
  selector; tripAddonsStore keys its lists by account through getState.
- Server lint (knip): TripAddonRow was exported without a reader outside
  its file.
- Client lint and Client types: no-unused-vars and the strict errors in
  useTripPlanner.ts went down by one, so their entries are lowered.
2026-11-21 14:00:02 +01:00