forked from Cutlery/immich
* refactor: user repository * refactor: user module * refactor: move database into infra * refactor(cli): use user core * chore: import path * chore: tests
29 lines
944 B
TypeScript
29 lines
944 B
TypeScript
import { Process, Processor } from '@nestjs/bull';
|
|
import { InjectRepository } from '@nestjs/typeorm';
|
|
import { Repository } from 'typeorm';
|
|
import { AssetEntity, SmartInfoEntity } from '@app/infra';
|
|
import { Job } from 'bull';
|
|
import { AssetResponseDto } from '../../api-v1/asset/response-dto/asset-response.dto';
|
|
import { assetUtils } from '@app/common/utils';
|
|
|
|
@Processor('background-task')
|
|
export class BackgroundTaskProcessor {
|
|
constructor(
|
|
@InjectRepository(AssetEntity)
|
|
private assetRepository: Repository<AssetEntity>,
|
|
|
|
@InjectRepository(SmartInfoEntity)
|
|
private smartInfoRepository: Repository<SmartInfoEntity>,
|
|
) {}
|
|
|
|
// TODO: Should probably use constants / Interfaces for Queue names / data
|
|
@Process('delete-file-on-disk')
|
|
async deleteFileOnDisk(job: Job<{ assets: AssetResponseDto[] }>) {
|
|
const { assets } = job.data;
|
|
|
|
for (const asset of assets) {
|
|
assetUtils.deleteFiles(asset);
|
|
}
|
|
}
|
|
}
|