mirror of
https://github.com/mauriceboe/TREK.git
synced 2026-11-28 07:30:04 +00:00
refactor(trip-membership): domains ask TripAccessService who may see a trip
Thirty services, controllers, MCP tools and RPC handlers outside the trips domain injected TripsRepository for one call, findAccessible. They now inject TripAccessService from the trip-membership leaf, in the same constructor slot under the same field name; it answers with the same access row (or undefined) and binds the id exactly as given, so each caller keeps its own coercion and its own 404, 403 or tool error.
This commit is contained in:
@@ -15,13 +15,11 @@ import {
|
||||
} from './transit-itinerary.helpers';
|
||||
import { noAccess, permissionDenied } from '../../mcp/tools/_shared';
|
||||
import { RateLimitService } from '../common/rate-limit.service';
|
||||
import { InjectRepository } from '@mikro-orm/nestjs';
|
||||
import { Trips } from '../../db/entities/Trips.entity';
|
||||
import type { TripsRepository } from '../../db/repositories/Trips.repository';
|
||||
import { DaysService } from '../days/days.service';
|
||||
import { ReservationsService } from '../reservations/reservations.service';
|
||||
import { SCHEDULED_TRANSIT_MODES, type TransitItinerary } from './transit.helpers';
|
||||
import { TransitService } from './transit.service';
|
||||
import { TripAccessService } from '../trip-membership/trip-access.service';
|
||||
|
||||
const TRANSIT_RATE_WINDOW = 15 * 60 * 1000;
|
||||
|
||||
@@ -65,9 +63,9 @@ export class TransitMcp {
|
||||
private readonly days: DaysService,
|
||||
private readonly reservations: ReservationsService,
|
||||
// Plan 4 Task 2 — canAccessTrip's own DatabaseService delegation is gone:
|
||||
// this injects TripsRepository directly (same constructor slot) and
|
||||
// this injects TripAccessService (trip-membership) (same constructor slot) and
|
||||
// calls findAccessible.
|
||||
@InjectRepository(Trips) private readonly trips: TripsRepository,
|
||||
private readonly trips: TripAccessService,
|
||||
private readonly guards: McpToolGuardsService,
|
||||
// The limiter RateLimitModule provides, so its store is the one every
|
||||
// other caller counts in. The MCP buckets (mcp_transit_*) are keyed by
|
||||
|
||||
@@ -13,6 +13,7 @@ import { Users } from '../../db/entities/Users.entity';
|
||||
import { Trips } from '../../db/entities/Trips.entity';
|
||||
import { GoogleQuotaModule } from '../google-quota/google-quota.module';
|
||||
import { AppConfigModule } from '../app-config/app-config.module';
|
||||
import { TripMembershipModule } from '../trip-membership/trip-membership.module';
|
||||
|
||||
/**
|
||||
* Transit domain (#1065) — the Transitous/MOTIS proxy, with the optional
|
||||
@@ -32,7 +33,7 @@ import { AppConfigModule } from '../app-config/app-config.module';
|
||||
*/
|
||||
@Module({
|
||||
// DaysModule + ReservationsModule: TransitMcp's create_transit_journey injects both.
|
||||
imports: [AppConfigModule, McpSharedModule, RateLimitModule, DaysModule, ReservationsModule, MikroOrmModule.forFeature([AppSettings, Users, Trips]), GoogleQuotaModule],
|
||||
imports: [TripMembershipModule, AppConfigModule, McpSharedModule, RateLimitModule, DaysModule, ReservationsModule, MikroOrmModule.forFeature([AppSettings, Users, Trips]), GoogleQuotaModule],
|
||||
controllers: [TransitController],
|
||||
providers: [TransitService, TransitMcp, GoogleTransitProvider],
|
||||
exports: [TransitService],
|
||||
|
||||
Reference in New Issue
Block a user