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(trips): end a plugin-added member's MCP sessions where the trip opened an addon
Maurice1a6639eb74ba
diff --git a/server/src/nest/trips/trips.rpc.ts b/server/src/nest/trips/trips.rpc.tsindex ce84526bf..50b34499d 100644--- a/server/src/nest/trips/trips.rpc.ts+++ b/server/src/nest/trips/trips.rpc.ts@@ -8,6 +8,7 @@ import { PluginController, PluginMethod } from '../../nest-rpc/rpc-kit/decoratorimport type { PluginRpcContext } from '../../nest-rpc/rpc-kit/types';import { schemaMessage, rowIdParam } from '../../nest-rpc/rpc-params';import { AccommodationsService } from '../accommodations/accommodations.service';+import { TripAddonsService } from '../addons/trip-addons.service';import { DaysService } from '../days/days.service';import { RealtimeService } from '../realtime/realtime.service';import { ReservationsService } from '../reservations/reservations.service';@@ -57,6 +58,7 @@ export class TripsRpc {// `.isOwner` used since Task 0b — `EntityManager` is `@Global()`, so no// module needs new wiring. Appended last, per this class's own convention.private readonly em: EntityManager,+ private readonly tripAddons: TripAddonsService,) {}@PluginMethod('trips.getById', { permission: 'db:read:trips' })@@ -219,6 +221,7 @@ export class TripsRpc {// The open planners learn of the member as they do from REST and MCP. A// plugin has no socket of its own, so the whole room hears it.if (result.joined) {+ await this.tripAddons.reattachJoinedMember(tripId, targetUserId);const member = await this.roster.findMember(tripId, targetUserId);if (member) this.realtime.broadcast(tripId, 'member:added', { member });}diff --git a/server/tests/helpers/plugin-host.ts b/server/tests/helpers/plugin-host.tsindex e54e2455c..36ec2ec58 100644--- a/server/tests/helpers/plugin-host.ts+++ b/server/tests/helpers/plugin-host.ts@@ -613,6 +613,8 @@ export async function createPluginRpcHostParts(accommodations,members,(await sharedTestOrm(db)).em,+ // TripAddonsService: ending a joined member's MCP sessions has its own suites.+ { reattachJoinedMember: async () => {} } as never,),new CostsRpc(budget, new TripAccessService(await createTestTripsRepo(db)), realtime, guards, membership),new ReservationsRpc(reservations, realtime, guards),diff --git a/server/tests/helpers/rpc-host-deps.ts b/server/tests/helpers/rpc-host-deps.tsindex 44699895b..e98e860a1 100644--- a/server/tests/helpers/rpc-host-deps.ts+++ b/server/tests/helpers/rpc-host-deps.ts@@ -81,6 +81,7 @@ export function allRpcControllers(): object[] {anyService(),anyService(),anyService(),+ anyService(),),new CostsRpc(anyService(), anyService(), anyService(), anyService(), anyService()),new ReservationsRpc(anyService(), anyService(), anyService()),diff --git a/server/tests/unit/plugins/rpc-fallbacks.test.ts b/server/tests/unit/plugins/rpc-fallbacks.test.tsindex 7aa220762..9149322e8 100644--- a/server/tests/unit/plugins/rpc-fallbacks.test.ts+++ b/server/tests/unit/plugins/rpc-fallbacks.test.ts@@ -281,6 +281,7 @@ describe('service errors are translated into the RPC taxonomy', () => {{} as never,{} as never,em,+ {} as never,);return new PluginRpcHost('p', ALL, makeDeps(), createTestPluginRegistry([rpc]));}@@ -416,7 +417,7 @@ describe('every schema-validated method rejects a payload its schema refuses', (new PlacesRpc(anything, anything, realtime(), guards, anything),new DaysRpc(anything, realtime(), guards, anything),new PackingRpc(anything, realtime(), guards),- new TripsRpc(anything, anything, anything, anything, realtime(), guards, anything, anything, em),+ new TripsRpc(anything, anything, anything, anything, realtime(), guards, anything, anything, em, anything),new AccommodationsRpc(anything, realtime(), guards),new ReservationsRpc(anything, realtime(), guards),]);diff --git a/server/tests/unit/plugins/rpc-host-inv-strip.test.ts b/server/tests/unit/plugins/rpc-host-inv-strip.test.tsindex 54badebb4..2c06c4b87 100644--- a/server/tests/unit/plugins/rpc-host-inv-strip.test.ts+++ b/server/tests/unit/plugins/rpc-host-inv-strip.test.ts@@ -48,7 +48,18 @@ const tripsRegistry = () => {getRepository: () => ({ findRaw: async () => ({ id: 1, title: 'Japan', feed_token: null }) }),} as unknown as EntityManager;return createTestPluginRegistry([- new TripsRpc({} as never, {} as never, {} as never, {} as never, {} as never, guards, {} as never, {} as never, em),+ new TripsRpc(+ {} as never,+ {} as never,+ {} as never,+ {} as never,+ {} as never,+ guards,+ {} as never,+ {} as never,+ em,+ {} as never,+ ),]);};diff --git a/server/tests/unit/trips/trips.rpc.test.ts b/server/tests/unit/trips/trips.rpc.test.tsindex d0b0ebbe3..28f0b7b7c 100644--- a/server/tests/unit/trips/trips.rpc.test.ts+++ b/server/tests/unit/trips/trips.rpc.test.ts@@ -17,6 +17,7 @@ import { PluginGuards } from '../../../src/nest-rpc/plugin-guards.service';import { createTestPluginRegistry } from '../../../src/nest-rpc/rpc-kit/testing';import type { AccommodationsService } from '../../../src/nest/accommodations/accommodations.service';import type { AddonsService } from '../../../src/nest/addons/addons.service';+import type { TripAddonsService } from '../../../src/nest/addons/trip-addons.service';import type { DaysService } from '../../../src/nest/days/days.service';import type { PermissionsService } from '../../../src/nest/permissions/permissions.service';import { PluginRpcHost } from '../../../src/nest/plugins/host/rpc-host';@@ -141,7 +142,20 @@ export function build({ isAddonEnabled: vi.fn(() => true) } as unknown as AddonsService,{ getRole: vi.fn(async () => 'user') } as unknown as UsersRepository,);- const rpc = new TripsRpc(trips, reservations, days, membership, realtime, guards, accommodations, roster, em);+ const tripAddons = { reattachJoinedMember: vi.fn(async () => undefined) } as unknown as TripAddonsService &+ Record<string, ReturnType<typeof vi.fn>>;+ const rpc = new TripsRpc(+ trips,+ reservations,+ days,+ membership,+ realtime,+ guards,+ accommodations,+ roster,+ em,+ tripAddons,+ );const host = (...grants: string[]) =>new PluginRpcHost('p',@@ -149,7 +163,7 @@ export function build(makeDeps(),createTestPluginRegistry([rpc]),);- return { trips, reservations, days, accommodations, roster, membership, realtime, permissions, host };+ return { trips, reservations, days, accommodations, roster, membership, realtime, permissions, tripAddons, host };}describe('TripsRpc reads', () => {@@ -238,6 +252,7 @@ describe('TripsRpc reads', () => {f.accommodations,f.roster,em,+ f.tripAddons,);const host = new PluginRpcHost('p', new Set(ALL_TRIP_GRANTS), makeDeps(), createTestPluginRegistry([rpc]));@@ -367,6 +382,8 @@ describe('TripsRpc membership', () => {const f = build();expect((await f.host().dispatch(req('trips.addMember', { tripId: 1, userId: 7 }), 42)).ok).toBe(true);expect(f.membership.joinTripAsMember).toHaveBeenCalledWith(1, 7, 42);+ // The joined member's MCP session is ended where the trip opened an addon, as REST, MCP and invites do.+ expect(f.tripAddons.reattachJoinedMember).toHaveBeenCalledWith(1, 7);// The whole room hears it: a plugin has no socket to leave out.expect(f.realtime.broadcast).toHaveBeenCalledWith(1, 'member:added', {member: { id: 7, username: 'bob', role: 'member' },@@ -378,6 +395,7 @@ describe('TripsRpc membership', () => {vi.mocked(f.membership.joinTripAsMember).mockResolvedValueOnce({ joined: false, tripId: 1 });expect((await f.host().dispatch(req('trips.addMember', { tripId: 1, userId: 7 }), 42)).ok).toBe(true);expect(f.roster.findMember).not.toHaveBeenCalled();+ expect(f.tripAddons.reattachJoinedMember).not.toHaveBeenCalled();expect(f.realtime.broadcast).not.toHaveBeenCalled();});