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

34 lines
944 B
TypeScript
Raw Normal View History

/*
* SPDX-FileCopyrightText: syuilo and other misskey contributors
* SPDX-License-Identifier: AGPL-3.0-only
*/
import { Injectable } from '@nestjs/common';
2022-09-17 21:27:08 +03:00
import type Logger from '@/logger.js';
import { DriveService } from '@/core/DriveService.js';
import { bindThis } from '@/decorators.js';
2022-09-17 21:27:08 +03:00
import { QueueLoggerService } from '../QueueLoggerService.js';
import type * as Bull from 'bullmq';
2022-09-17 21:27:08 +03:00
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(
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
}
@bindThis
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';
}
}