mirror of
https://github.com/mauriceboe/TREK.git
synced 2026-12-05 18:34:09 +00:00
feat(server): let a trip owner switch trip addons for one trip
A trip can now turn a trip addon (lists, costs, documents, collab, road trip, tours) on or off for itself, whatever the instance switch says. No row in the new trip_addon_overrides table means the trip follows the instance; a row is the owner's choice. Going back to the instance setting deletes the row, and no addon data is touched either way. - GET/PUT /api/trips/:tripId/addons[/:addonId] (every member reads, the owner writes) and the MCP tools get_trip_addons and set_trip_addon, on the shared tripAddons contract; tripAddons:changed tells the members. - Every trip-scoped addon surface asks the trip: REST through TripAddonGuard, MCP through a per-call gate on the named or pinned trip, plugin RPC and events, the share link, the offline bundle, reminders, doc sync, the assistant (tools, keep_attached_file), booking costs, the trip summary prompt, and the cross-trip tour reads (library, Atlas stats, collection save). - Routes without a trip open while the addon is on in any of the user's trips. Switching an addon on that the instance has off ends the members' MCP sessions so they reconnect with its tools. - A copied trip takes its owner's choices along. Behaviour changes: an anonymous call to an addon route that is off now gets 401 instead of 404, and with an instance switch off the packing, todo and files plugin RPC methods, the files MCP tools, todo reminder mails, core plugin events, plugin view contributions, the share link's lists, costs and chat sections and the offline bundle's lists follow it.
This commit is contained in:
@@ -2,11 +2,19 @@ import { Addons } from '../../db/entities/Addons.entity';
|
||||
import { AppSettings } from '../../db/entities/AppSettings.entity';
|
||||
import { PhotoProviderFields } from '../../db/entities/PhotoProviderFields.entity';
|
||||
import { PhotoProviders } from '../../db/entities/PhotoProviders.entity';
|
||||
import { TripAddonOverrides } from '../../db/entities/TripAddonOverrides.entity';
|
||||
import { Users } from '../../db/entities/Users.entity';
|
||||
import { PermissionsModule } from '../permissions/permissions.module';
|
||||
import { RealtimeModule } from '../realtime/realtime.module';
|
||||
import { TripMembershipModule } from '../trip-membership/trip-membership.module';
|
||||
import { AddonGuard } from './addon.guard';
|
||||
import { AddonsController } from './addons.controller';
|
||||
import { AddonsMcp } from './addons.mcp';
|
||||
import { AddonsService } from './addons.service';
|
||||
import { TripAddonGuard } from './trip-addon.guard';
|
||||
import { TripAddonsController } from './trip-addons.controller';
|
||||
import { TripAddonsMcp } from './trip-addons.mcp';
|
||||
import { TripAddonsService } from './trip-addons.service';
|
||||
import { MikroOrmModule } from '@mikro-orm/nestjs';
|
||||
import { Module } from '@nestjs/common';
|
||||
|
||||
@@ -32,11 +40,27 @@ import { Module } from '@nestjs/common';
|
||||
* added by Task 5: `googleKeySource` passes `UsersRepository` explicitly to
|
||||
* `instance-api-keys.ts`'s resolveApiKey now, instead of that file resolving
|
||||
* one off the ambient request context.
|
||||
*
|
||||
* TripAddonsService answers whether a trip addon applies to one trip (the
|
||||
* owner's override, else the instance switch) and owns the per-trip overrides
|
||||
* behind GET/PUT /api/trips/:tripId/addons and their MCP tools. It asks
|
||||
* TripMembershipModule, a leaf, whether the caller may see the trip; its
|
||||
* routes take TripAccessGuard and TripOwnerGuard from PermissionsModule, and
|
||||
* RealtimeModule is named so a hand-built test module that imports this one
|
||||
* resolves the broadcast without listing it.
|
||||
*
|
||||
* TripAddonGuard is the trip-scoped twin of AddonGuard: it answers @RequireAddon
|
||||
* with AddonsService.isEnabledForTrip after TripAccessGuard parked the trip.
|
||||
*/
|
||||
@Module({
|
||||
imports: [MikroOrmModule.forFeature([Addons, PhotoProviders, PhotoProviderFields, AppSettings, Users])],
|
||||
controllers: [AddonsController],
|
||||
providers: [AddonsService, AddonGuard, AddonsMcp],
|
||||
exports: [AddonsService, AddonGuard],
|
||||
imports: [
|
||||
MikroOrmModule.forFeature([Addons, PhotoProviders, PhotoProviderFields, AppSettings, Users, TripAddonOverrides]),
|
||||
PermissionsModule,
|
||||
RealtimeModule,
|
||||
TripMembershipModule,
|
||||
],
|
||||
controllers: [AddonsController, TripAddonsController],
|
||||
providers: [AddonsService, AddonGuard, TripAddonGuard, AddonsMcp, TripAddonsService, TripAddonsMcp],
|
||||
exports: [AddonsService, AddonGuard, TripAddonGuard, TripAddonsService],
|
||||
})
|
||||
export class AddonsModule {}
|
||||
|
||||
Reference in New Issue
Block a user