diff --git a/server/src/controllers/integrity.controller.ts b/server/src/controllers/integrity.controller.ts index 214bf86b70..15e2b1c2e9 100644 --- a/server/src/controllers/integrity.controller.ts +++ b/server/src/controllers/integrity.controller.ts @@ -70,7 +70,7 @@ export class IntegrityController { }) @Authenticated({ permission: Permission.Maintenance, admin: true }) async deleteIntegrityReport(@Auth() auth: AuthDto, @Param() { id }: UUIDv7ParamDto): Promise { - await this.service.deleteIntegrityReport(auth, id); + await this.service.deleteIntegrityReport(auth.user.id, id); } @Get('report/:type/csv') diff --git a/server/src/services/integrity.service.spec.ts b/server/src/services/integrity.service.spec.ts index 1b0beee588..5cf6bf4557 100644 --- a/server/src/services/integrity.service.spec.ts +++ b/server/src/services/integrity.service.spec.ts @@ -101,14 +101,7 @@ describe(IntegrityService.name, () => { fileAssetId: null, }); - await sut.deleteIntegrityReport( - { - user: { - id: 'userId', - }, - } as never, - 'id', - ); + await sut.deleteIntegrityReport('userId', 'id'); expect(mocks.asset.updateAll).toHaveBeenCalledWith(['assetId'], { deletedAt: expect.any(Date), @@ -133,14 +126,7 @@ describe(IntegrityService.name, () => { fileAssetId: 'fileAssetId', }); - await sut.deleteIntegrityReport( - { - user: { - id: 'userId', - }, - } as never, - 'id', - ); + await sut.deleteIntegrityReport('userId', 'id'); expect(mocks.asset.deleteFiles).toHaveBeenCalledWith([{ id: 'fileAssetId' }]); }); @@ -155,14 +141,7 @@ describe(IntegrityService.name, () => { fileAssetId: null, }); - await sut.deleteIntegrityReport( - { - user: { - id: 'userId', - }, - } as never, - 'id', - ); + await sut.deleteIntegrityReport('userId', 'id'); expect(mocks.storage.unlink).toHaveBeenCalledWith('/path/to/file'); expect(mocks.integrityReport.deleteById).toHaveBeenCalledWith('id'); diff --git a/server/src/services/integrity.service.ts b/server/src/services/integrity.service.ts index de3b31db96..4978f06de2 100644 --- a/server/src/services/integrity.service.ts +++ b/server/src/services/integrity.service.ts @@ -6,7 +6,6 @@ import { pipeline } from 'node:stream/promises'; import { JOBS_LIBRARY_PAGINATION_SIZE } from 'src/constants'; import { StorageCore } from 'src/cores/storage.core'; import { OnEvent, OnJob } from 'src/decorators'; -import { AuthDto } from 'src/dtos/auth.dto'; import { IntegrityGetReportDto, IntegrityReportResponseDto, @@ -171,7 +170,7 @@ export class IntegrityService extends BaseService { }); } - async deleteIntegrityReport(auth: AuthDto, id: string): Promise { + async deleteIntegrityReport(userId: string, id: string): Promise { const { path, assetId, fileAssetId } = await this.integrityRepository.getById(id); if (assetId) { @@ -182,7 +181,7 @@ export class IntegrityService extends BaseService { await this.eventRepository.emit('AssetTrashAll', { assetIds: [assetId], - userId: auth.user.id, + userId, }); await this.integrityRepository.deleteById(id);