misskey/packages/backend/src/queue/processors/CheckExpiredMutingsProcessorService.ts
riku6460 757eae25bf
Revert "Merge pull request #86 from MisskeyIO/revert-bullmq"
This reverts commit e8cf53a1ea.

Revert "外部サーバーへの配送が行われない問題を修正 (たぶん) (#98)"

This reverts commit 53931ec59a.

Revert "fix(backend): restore start method in QueueProcessorService (#87)"

This reverts commit e88617e3c3.
2023-07-23 02:11:31 +09:00

46 lines
1.4 KiB
TypeScript

import { Inject, Injectable } from '@nestjs/common';
import { In } from 'typeorm';
import { DI } from '@/di-symbols.js';
import type { MutingsRepository } from '@/models/index.js';
import type { Config } from '@/config.js';
import type Logger from '@/logger.js';
import { bindThis } from '@/decorators.js';
import { UserMutingService } from '@/core/UserMutingService.js';
import { QueueLoggerService } from '../QueueLoggerService.js';
import type * as Bull from 'bullmq';
@Injectable()
export class CheckExpiredMutingsProcessorService {
private logger: Logger;
constructor(
@Inject(DI.config)
private config: Config,
@Inject(DI.mutingsRepository)
private mutingsRepository: MutingsRepository,
private userMutingService: UserMutingService,
private queueLoggerService: QueueLoggerService,
) {
this.logger = this.queueLoggerService.logger.createSubLogger('check-expired-mutings');
}
@bindThis
public async process(): Promise<void> {
this.logger.info('Checking expired mutings...');
const expired = await this.mutingsRepository.createQueryBuilder('muting')
.where('muting.expiresAt IS NOT NULL')
.andWhere('muting.expiresAt < :now', { now: new Date() })
.innerJoinAndSelect('muting.mutee', 'mutee')
.getMany();
if (expired.length > 0) {
await this.userMutingService.unmute(expired);
}
this.logger.succ('All expired mutings checked.');
}
}