Sharkey/packages/backend/src/queue/processors/DeleteFileProcessorService.ts

32 lines
899 B
TypeScript
Raw Normal View History

2022-09-17 21:27:08 +03:00
import { Inject, Injectable } from '@nestjs/common';
import { DI } from '@/di-symbols.js';
import { Config } from '@/config.js';
import type Logger from '@/logger.js';
import { DriveService } from '@/core/DriveService.js';
import { QueueLoggerService } from '../QueueLoggerService.js';
import type Bull from 'bull';
import type { ObjectStorageFileJobData } from '../types.js';
@Injectable()
export class DeleteFileProcessorService {
2022-09-18 21:11:50 +03:00
private logger: Logger;
2022-09-17 21:27:08 +03:00
constructor(
@Inject(DI.config)
private config: Config,
private driveService: DriveService,
private queueLoggerService: QueueLoggerService,
) {
2022-09-18 21:11:50 +03:00
this.logger = this.queueLoggerService.logger.createSubLogger('delete-file');
2022-09-17 21:27:08 +03:00
}
public async process(job: Bull.Job<ObjectStorageFileJobData>): Promise<string> {
const key: string = job.data.key;
await this.driveService.deleteObjectStorageFile(key);
return 'Success';
}
}