fix(server): hold DELETE bodies to the same contract as every other write

The body-contract boot gate only looked at POST/PUT/PATCH, so a DELETE that
reads a body slipped past it. Two do; one was already typed, the other read
photo_id straight off an untyped Record. Give it a contract from shared like
everything else, then add DELETE to the gate so the next one cannot repeat it.
This commit is contained in:
Maurice
2026-08-23 09:34:53 +02:00
committed by Maurice
parent 3f8a7a1ea9
commit b163c1e05d
5 changed files with 30 additions and 4 deletions
@@ -10,6 +10,10 @@ const MUTATION_METHODS = new Set<RequestMethod>([
RequestMethod.POST,
RequestMethod.PUT,
RequestMethod.PATCH,
// DELETE belongs here too. It is rare for one to read a body, but the two that
// do are writes like any other, and leaving the method out meant their bodies
// reached the handler with nothing having looked at them.
RequestMethod.DELETE,
]);
/**
+2
View File
@@ -5,6 +5,7 @@ import {
immichSearchSchema,
immichSettingsSchema,
immichTestSchema,
removeTripPhotoSchema,
setTripPhotoSharingSchema,
synologySearchSchema,
synologySettingsSchema,
@@ -31,4 +32,5 @@ export class SynologySearchDto extends createZodDto(synologySearchSchema) {}
export class AddTripPhotosDto extends createZodDto(addTripPhotosSchema) {}
export class SetTripPhotoSharingDto extends createZodDto(setTripPhotoSharingSchema) {}
export class RemoveTripPhotoDto extends createZodDto(removeTripPhotoSchema) {}
export class CreateAlbumLinkDto extends createZodDto(createAlbumLinkSchema) {}
@@ -5,7 +5,7 @@ import type { Selection } from './memories.helpers';
import { MemoriesService } from './memories.service';
import { JwtAuthGuard } from '../auth/jwt-auth.guard';
import { CurrentUser } from '../auth/current-user.decorator';
import { AddTripPhotosDto, CreateAlbumLinkDto, SetTripPhotoSharingDto } from './memories.dto';
import { AddTripPhotosDto, CreateAlbumLinkDto, RemoveTripPhotoDto, SetTripPhotoSharingDto } from './memories.dto';
/**
* /api/integrations/memories/unified — provider-agnostic trip photo + album-link
@@ -69,7 +69,7 @@ export class UnifiedMemoriesController {
async removePhoto(
@CurrentUser() user: User,
@Param('tripId') tripId: string,
@Body() body: Record<string, unknown>,
@Body() body: RemoveTripPhotoDto,
@Res() res: Response,
): Promise<void> {
const result = this.memories.removeTripPhoto(tripId, user.id, Number(body?.photo_id));