mirror of
https://github.com/mauriceboe/TREK.git
synced 2026-11-27 23:27:31 +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:
@@ -6,6 +6,7 @@ import { AppSettings } from '../../db/entities/AppSettings.entity';
|
||||
import { Users } from '../../db/entities/Users.entity';
|
||||
import { Trips } from '../../db/entities/Trips.entity';
|
||||
import { processRooms, RoomRegistry, roomsSlot } from './ws-state';
|
||||
import { TripMembershipModule } from '../trip-membership/trip-membership.module';
|
||||
|
||||
/**
|
||||
* The transport, kept out of RealtimeModule on purpose.
|
||||
@@ -28,7 +29,7 @@ import { processRooms, RoomRegistry, roomsSlot } from './ws-state';
|
||||
// DatabaseService onto UsersRepository/AppSettingsRepository. Trips: Plan 4
|
||||
// Task 2 — handleJoin's own canAccessTrip delegate, now TripsRepository
|
||||
// directly.
|
||||
imports: [EphemeralTokenModule, MikroOrmModule.forFeature([Users, AppSettings, Trips])],
|
||||
imports: [TripMembershipModule, EphemeralTokenModule, MikroOrmModule.forFeature([Users, AppSettings, Trips])],
|
||||
// The room registry is the process-wide in-memory one; the constructor
|
||||
// below hands whichever one the container resolved to the broadcast
|
||||
// functions, so the gateway and the broadcasts never use two registries.
|
||||
|
||||
@@ -16,8 +16,6 @@ import { AppSettings } from '../../db/entities/AppSettings.entity';
|
||||
import type { AppSettingsRepository } from '../../db/repositories/AppSettings.repository';
|
||||
import { Users } from '../../db/entities/Users.entity';
|
||||
import type { UsersRepository } from '../../db/repositories/Users.repository';
|
||||
import { Trips } from '../../db/entities/Trips.entity';
|
||||
import type { TripsRepository } from '../../db/repositories/Trips.repository';
|
||||
import { User } from '../../types';
|
||||
import { logError } from '../audit/audit-log.logger';
|
||||
import {
|
||||
@@ -33,6 +31,7 @@ import {
|
||||
import { JOURNEY_ACCESS, type JourneyAccess } from './journey-access.types';
|
||||
import { readAppSetting } from '../common/app-settings.registry';
|
||||
import { runningVersion } from '../../app-config';
|
||||
import { TripAccessService } from '../trip-membership/trip-access.service';
|
||||
|
||||
const HEARTBEAT_INTERVAL = 30_000;
|
||||
|
||||
@@ -64,9 +63,9 @@ export class RealtimeGateway
|
||||
|
||||
constructor(
|
||||
// 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 from `handleJoin`.
|
||||
@InjectRepository(Trips) private readonly trips: TripsRepository,
|
||||
private readonly trips: TripAccessService,
|
||||
private readonly tokens: EphemeralTokenService,
|
||||
/*
|
||||
* For the book rooms, and injected rather than reimplemented: who may open
|
||||
|
||||
Reference in New Issue
Block a user