The most complete open-source travel planner: real-time collaboration, bookings, budgets, packing lists, journals, offline PWA, SSO and an AI-ready MCP server, with planet-wide place search and routing built in.
TypeScript budget-trackercollaborativedockeritinerarymcp-serveroffline-firstopen-sourceopenstreetmappacking-listpwareal-timeself-hostedselfhostedtraveltravel-apptravel-journaltravel-plannertripitwanderlog
fix(plugins): let a file write past Documents off only for the targets it writes
Maurice907fc95b00f7
diff --git a/server/src/nest/files/files.rpc.ts b/server/src/nest/files/files.rpc.tsindex 6f153d539..c8a8f5ebe 100644--- a/server/src/nest/files/files.rpc.ts+++ b/server/src/nest/files/files.rpc.ts@@ -182,7 +182,11 @@ export class FilesRpc {const file = await this.files.getFileById(fileId, tripId);if (!file) throw new ForbiddenResource(`no file ${fileId} on trip ${tripId}`);const opts = asPayload(params.opts) as { reservation_id?: number; assignment_id?: number; place_id?: number };- await this.requireReachable(tripId, file, opts);+ await this.requireReachable(tripId, file, {+ reservation_id: opts.reservation_id,+ assignment_id: opts.assignment_id,+ place_id: opts.place_id,+ });// A link target on another trip would otherwise attach this trip's file to it.const foreign = await this.files.findForeignLinkTarget(tripId, opts);if (foreign) throw new ForbiddenResource(`${foreign} does not belong to trip ${tripId}`);@@ -206,7 +210,7 @@ export class FilesRpc {place_id?: number | null;reservation_id?: number | null;};- await this.requireReachable(tripId, current, input);+ await this.requireReachable(tripId, current, { place_id: input.place_id, reservation_id: input.reservation_id });const foreign = await this.files.findForeignLinkTarget(tripId, {reservation_id: input.reservation_id ?? null,place_id: input.place_id ?? null,diff --git a/server/tests/unit/files/files.rpc.test.ts b/server/tests/unit/files/files.rpc.test.tsindex 9431d3870..b1cca157e 100644--- a/server/tests/unit/files/files.rpc.test.ts+++ b/server/tests/unit/files/files.rpc.test.ts@@ -260,6 +260,10 @@ describe('FilesRpc with Documents off for the trip', () => {expect(await forbidden(host.dispatch(req('files.createLink', { tripId: 1, fileId: 2, opts: {} }), 42)),).toMatchObject({ code: 'RESOURCE_FORBIDDEN' });+ const unwritten = req('files.update', { tripId: 1, fileId: 2, input: { description: 'x', budget_item_id: 9 } });+ expect(await forbidden(host.dispatch(unwritten, 42))).toMatchObject({ code: 'RESOURCE_FORBIDDEN' });+ const unlinked = req('files.createLink', { tripId: 1, fileId: 2, opts: { budget_item_id: 9 } });+ expect(await forbidden(host.dispatch(unlinked, 42))).toMatchObject({ code: 'RESOURCE_FORBIDDEN' });expect(f.files.updateFile).not.toHaveBeenCalled();const attach = req('files.update', { tripId: 1, fileId: 2, input: { reservation_id: 4 } });