mirror of
https://github.com/mauriceboe/TREK.git
synced 2026-11-23 05:21:15 +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:
@@ -108,7 +108,8 @@ const tripTagId = (s: Scene): number => {
|
||||
|
||||
/**
|
||||
* The planner: places and the tags their trip owns, the day plan, days, day
|
||||
* notes, categories, and the collection places copied into a trip.
|
||||
* notes, categories, the collection places copied into a trip, and the trip
|
||||
* addons its owner switches for it.
|
||||
*/
|
||||
export const plan: CaseGroup = {
|
||||
name: 'plan',
|
||||
@@ -455,6 +456,13 @@ export const plan: CaseGroup = {
|
||||
},
|
||||
expect: ['day:updated'],
|
||||
},
|
||||
{
|
||||
// The owner switches costs off for the trip: every tab gets the trip's addon list.
|
||||
tool: 'set_trip_addon',
|
||||
args: (s) => ({ tripId: s.trip.id, addonId: 'budget', enabled: false }),
|
||||
rest: { method: 'put', path: (s) => `/api/trips/${s.trip.id}/addons/budget`, body: () => ({ enabled: false }) },
|
||||
expect: ['tripAddons:changed'],
|
||||
},
|
||||
],
|
||||
exempt: [
|
||||
{
|
||||
|
||||
@@ -38,6 +38,7 @@ import { PluginUserConfig } from '../../../src/db/entities/PluginUserConfig.enti
|
||||
import { PluginUserErasureQueue } from '../../../src/db/entities/PluginUserErasureQueue.entity';
|
||||
import { Plugins } from '../../../src/db/entities/Plugins.entity';
|
||||
import { Settings } from '../../../src/db/entities/Settings.entity';
|
||||
import { TripAddonOverrides } from '../../../src/db/entities/TripAddonOverrides.entity';
|
||||
import { Users } from '../../../src/db/entities/Users.entity';
|
||||
import { PluginRpcRegistry } from '../../../src/nest-rpc/rpc-kit/registry';
|
||||
import type { PluginRpcRegistryService } from '../../../src/nest-rpc/rpc-kit/registry.service';
|
||||
@@ -269,6 +270,7 @@ describe('plugin boot vs registry scan ordering', () => {
|
||||
t2.repo(AppSettings),
|
||||
t2.repo(Users),
|
||||
new UnitOfWork(t2.em, new SqliteEngine()),
|
||||
t2.repo(TripAddonOverrides),
|
||||
);
|
||||
const auditLogRepo2 = t2.repo(AuditLog);
|
||||
const usersRepo2 = t2.repo(Users);
|
||||
|
||||
Reference in New Issue
Block a user