mirror of
https://github.com/immich-app/immich.git
synced 2026-05-18 03:10:24 +03:00
refactor: pass only userId to deleteIntegrityReport
Signed-off-by: izzy <me@insrt.uk>
This commit is contained in:
@@ -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')
|
||||||
|
|||||||
@@ -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');
|
||||||
|
|||||||
@@ -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);
|
||||||
|
|||||||
Reference in New Issue
Block a user