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

View File

@@ -70,7 +70,7 @@ export class IntegrityController {
})
@Authenticated({ permission: Permission.Maintenance, admin: true })
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')

View File

@@ -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');

View File

@@ -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<void> {
async deleteIntegrityReport(userId: string, id: string): Promise<void> {
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);