refactor: pass only userId to deleteIntegrityReport

Signed-off-by: izzy <me@insrt.uk>
This commit is contained in:
izzy
2026-02-12 11:02:22 +00:00
parent fbdeb0409e
commit 4908289879
3 changed files with 6 additions and 28 deletions
@@ -70,7 +70,7 @@ export class IntegrityController {
}) })
@Authenticated({ permission: Permission.Maintenance, admin: true }) @Authenticated({ permission: Permission.Maintenance, admin: true })
async deleteIntegrityReport(@Auth() auth: AuthDto, @Param() { id }: UUIDv7ParamDto): Promise<void> { async deleteIntegrityReport(@Auth() auth: AuthDto, @Param() { id }: UUIDv7ParamDto): Promise<void> {
await this.service.deleteIntegrityReport(auth, id); await this.service.deleteIntegrityReport(auth.user.id, id);
} }
@Get('report/:type/csv') @Get('report/:type/csv')
+3 -24
View File
@@ -101,14 +101,7 @@ describe(IntegrityService.name, () => {
fileAssetId: null, fileAssetId: null,
}); });
await sut.deleteIntegrityReport( await sut.deleteIntegrityReport('userId', 'id');
{
user: {
id: 'userId',
},
} as never,
'id',
);
expect(mocks.asset.updateAll).toHaveBeenCalledWith(['assetId'], { expect(mocks.asset.updateAll).toHaveBeenCalledWith(['assetId'], {
deletedAt: expect.any(Date), deletedAt: expect.any(Date),
@@ -133,14 +126,7 @@ describe(IntegrityService.name, () => {
fileAssetId: 'fileAssetId', fileAssetId: 'fileAssetId',
}); });
await sut.deleteIntegrityReport( await sut.deleteIntegrityReport('userId', 'id');
{
user: {
id: 'userId',
},
} as never,
'id',
);
expect(mocks.asset.deleteFiles).toHaveBeenCalledWith([{ id: 'fileAssetId' }]); expect(mocks.asset.deleteFiles).toHaveBeenCalledWith([{ id: 'fileAssetId' }]);
}); });
@@ -155,14 +141,7 @@ describe(IntegrityService.name, () => {
fileAssetId: null, fileAssetId: null,
}); });
await sut.deleteIntegrityReport( await sut.deleteIntegrityReport('userId', 'id');
{
user: {
id: 'userId',
},
} as never,
'id',
);
expect(mocks.storage.unlink).toHaveBeenCalledWith('/path/to/file'); expect(mocks.storage.unlink).toHaveBeenCalledWith('/path/to/file');
expect(mocks.integrityReport.deleteById).toHaveBeenCalledWith('id'); expect(mocks.integrityReport.deleteById).toHaveBeenCalledWith('id');
+2 -3
View File
@@ -6,7 +6,6 @@ import { pipeline } from 'node:stream/promises';
import { JOBS_LIBRARY_PAGINATION_SIZE } from 'src/constants'; import { JOBS_LIBRARY_PAGINATION_SIZE } from 'src/constants';
import { StorageCore } from 'src/cores/storage.core'; import { StorageCore } from 'src/cores/storage.core';
import { OnEvent, OnJob } from 'src/decorators'; import { OnEvent, OnJob } from 'src/decorators';
import { AuthDto } from 'src/dtos/auth.dto';
import { import {
IntegrityGetReportDto, IntegrityGetReportDto,
IntegrityReportResponseDto, IntegrityReportResponseDto,
@@ -171,7 +170,7 @@ export class IntegrityService extends BaseService {
}); });
} }
async deleteIntegrityReport(auth: AuthDto, id: string): Promise<void> { async deleteIntegrityReport(userId: string, id: string): Promise<void> {
const { path, assetId, fileAssetId } = await this.integrityRepository.getById(id); const { path, assetId, fileAssetId } = await this.integrityRepository.getById(id);
if (assetId) { if (assetId) {
@@ -182,7 +181,7 @@ export class IntegrityService extends BaseService {
await this.eventRepository.emit('AssetTrashAll', { await this.eventRepository.emit('AssetTrashAll', {
assetIds: [assetId], assetIds: [assetId],
userId: auth.user.id, userId,
}); });
await this.integrityRepository.deleteById(id); await this.integrityRepository.deleteById(id);