mirror of
https://github.com/mauriceboe/TREK.git
synced 2026-12-05 18:34:09 +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:
@@ -1,6 +1,5 @@
|
||||
import { Controller, HttpException, Param, Post, UploadedFile, UseGuards, UseInterceptors } from '@nestjs/common';
|
||||
import { FileInterceptor } from '@nestjs/platform-express';
|
||||
import { InjectRepository } from '@mikro-orm/nestjs';
|
||||
import { memoryStorage } from 'multer';
|
||||
import type { ReceiptScanStartResponse } from '@trek/shared';
|
||||
import type { User } from '../../types';
|
||||
@@ -8,12 +7,11 @@ import { ADDON_IDS } from '../../addons';
|
||||
import { AddonsService } from '../addons/addons.service';
|
||||
import { JwtAuthGuard } from '../auth-core/jwt-auth.guard';
|
||||
import { CurrentUser } from '../auth-core/current-user.decorator';
|
||||
import { Trips } from '../../db/entities/Trips.entity';
|
||||
import type { TripsRepository } from '../../db/repositories/Trips.repository';
|
||||
import { PermissionsService } from '../permissions/permissions.service';
|
||||
import { ImportJobsService } from '../booking-import/import-jobs.service';
|
||||
import { LlmParseService } from '../llm-parse/llm-parse.service';
|
||||
import { imageMimeType } from '../llm-parse/image-input';
|
||||
import { TripAccessService } from '../trip-membership/trip-access.service';
|
||||
|
||||
const MAX_FILE_BYTES = 10 * 1024 * 1024;
|
||||
|
||||
@@ -40,7 +38,7 @@ export class ReceiptScanController {
|
||||
constructor(
|
||||
private readonly importJobs: ImportJobsService,
|
||||
private readonly llmParse: LlmParseService,
|
||||
@InjectRepository(Trips) private readonly trips: TripsRepository,
|
||||
private readonly trips: TripAccessService,
|
||||
private readonly permissions: PermissionsService,
|
||||
private readonly addons: AddonsService,
|
||||
) {}
|
||||
|
||||
@@ -6,10 +6,11 @@ import { BookingImportModule } from '../booking-import/booking-import.module';
|
||||
import { LlmParseModule } from '../llm-parse/llm-parse.module';
|
||||
import { AddonsModule } from '../addons/addons.module';
|
||||
import { PermissionsModule } from '../permissions/permissions.module';
|
||||
import { TripMembershipModule } from '../trip-membership/trip-membership.module';
|
||||
|
||||
/** The Costs tab's receipt scan: an HTTP surface over the import job queue. */
|
||||
@Module({
|
||||
imports: [MikroOrmModule.forFeature([Trips]), BookingImportModule, LlmParseModule, AddonsModule, PermissionsModule],
|
||||
imports: [TripMembershipModule, MikroOrmModule.forFeature([Trips]), BookingImportModule, LlmParseModule, AddonsModule, PermissionsModule],
|
||||
controllers: [ReceiptScanController],
|
||||
})
|
||||
export class ReceiptScanModule {}
|
||||
|
||||
Reference in New Issue
Block a user