mirror of
https://github.com/immich-app/immich.git
synced 2026-03-22 21:49:59 +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 })
|
||||
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')
|
||||
|
||||
@@ -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');
|
||||
|
||||
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user