chore: bump version
fix: queue problem
This commit is contained in:
parent
c28afda4bf
commit
de6db7aefc
@ -72,7 +72,7 @@ export class QueueService {
|
||||
|
||||
this.systemQueue.add('autoNoteRemoval', {
|
||||
}, {
|
||||
repeat: { pattern: '0 0 * * *' },
|
||||
repeat: { pattern: '* */10 * * *' },
|
||||
removeOnComplete: true,
|
||||
});
|
||||
}
|
||||
|
@ -41,6 +41,7 @@ import { CleanChartsProcessorService } from './processors/CleanChartsProcessorSe
|
||||
import { CheckExpiredMutingsProcessorService } from './processors/CheckExpiredMutingsProcessorService.js';
|
||||
import { CleanProcessorService } from './processors/CleanProcessorService.js';
|
||||
import { AggregateRetentionProcessorService } from './processors/AggregateRetentionProcessorService.js';
|
||||
import { AutoNoteRemovalProcessorService } from './processors/AutoNoteRemovalProcessorService.js';}
|
||||
import { QueueLoggerService } from './QueueLoggerService.js';
|
||||
import { QUEUE, baseWorkerOptions } from './const.js';
|
||||
|
||||
@ -119,6 +120,7 @@ export class QueueProcessorService implements OnApplicationShutdown {
|
||||
private aggregateRetentionProcessorService: AggregateRetentionProcessorService,
|
||||
private checkExpiredMutingsProcessorService: CheckExpiredMutingsProcessorService,
|
||||
private cleanProcessorService: CleanProcessorService,
|
||||
private autoNoteRemovalProcessorService: AutoNoteRemovalProcessorService,
|
||||
) {
|
||||
this.logger = this.queueLoggerService.logger;
|
||||
|
||||
@ -147,6 +149,7 @@ export class QueueProcessorService implements OnApplicationShutdown {
|
||||
case 'aggregateRetention': return this.aggregateRetentionProcessorService.process();
|
||||
case 'checkExpiredMutings': return this.checkExpiredMutingsProcessorService.process();
|
||||
case 'clean': return this.cleanProcessorService.process();
|
||||
case 'autoNoteRemoval': return this.autoNoteRemovalProcessorService.process();
|
||||
default: throw new Error(`unrecognized job type ${job.name} for system`);
|
||||
}
|
||||
}, {
|
||||
|
@ -6,7 +6,7 @@
|
||||
import { Inject, Injectable } from '@nestjs/common';
|
||||
import { And, In, MoreThan, Not } from 'typeorm';
|
||||
import { DI } from '@/di-symbols.js';
|
||||
import type { MiUserNotePining, NotesRepository, UserNotePiningsRepository, UsersRepository } from '@/models/_.js';
|
||||
import type { AutoRemovalConditionRepository, MiUserNotePining, NotesRepository, UserNotePiningsRepository, UsersRepository } from '@/models/_.js';
|
||||
import type Logger from '@/logger.js';
|
||||
import type { MiNote } from '@/models/Note.js';
|
||||
import { bindThis } from '@/decorators.js';
|
||||
@ -21,9 +21,16 @@ export class AutoNoteRemovalProcessorService {
|
||||
constructor(
|
||||
@Inject(DI.notesRepository)
|
||||
private notesRepository: NotesRepository,
|
||||
|
||||
@Inject(DI.usersRepository)
|
||||
private usersRepository: UsersRepository,
|
||||
|
||||
@Inject(DI.userNotePiningsRepository)
|
||||
private userNotePiningsRepository: UserNotePiningsRepository,
|
||||
|
||||
@Inject(DI.autoRemovalConditionRepository)
|
||||
private autoRemovalConditionRepository: AutoRemovalConditionRepository,
|
||||
|
||||
private idService: IdService,
|
||||
private noteDeleteService: NoteDeleteService,
|
||||
private queueLoggerService: QueueLoggerService,
|
||||
@ -43,9 +50,7 @@ export class AutoNoteRemovalProcessorService {
|
||||
const now = Date.now();
|
||||
|
||||
for (const user of users) {
|
||||
if (user.autoRemovalCondition === null) {
|
||||
continue;
|
||||
}
|
||||
const autoRemovalCondition = await this.autoRemovalConditionRepository.findOneByOrFail({ id: user.autoRemovalConditionId });
|
||||
const pinings: MiUserNotePining[] = await this.userNotePiningsRepository.findBy({ userId: user.id });
|
||||
const piningNoteIds: string[] = pinings.map(pining => pining.noteId); // pining.note always undefined (bug?)
|
||||
|
||||
@ -54,16 +59,16 @@ export class AutoNoteRemovalProcessorService {
|
||||
visibility: Not(In(['public', 'home', 'followers'])),
|
||||
});
|
||||
const specifiedNoteIds: string[] = specifiedNotes.map(note => note.id);
|
||||
const deleteAfter: number = user.autoRemovalCondition.deleteAfter * 86400000;
|
||||
const deleteAfter: number = autoRemovalCondition.deleteAfter * 86400000;
|
||||
|
||||
// Delete notes
|
||||
let cursor: MiNote['id'] | null = null;
|
||||
let condition: string[] = [];
|
||||
if (user.autoRemovalCondition.noSpecifiedNotes === true) {
|
||||
if (autoRemovalCondition.noSpecifiedNotes === true) {
|
||||
condition = [...condition, ...specifiedNoteIds];
|
||||
}
|
||||
|
||||
if (user.autoRemovalCondition.noPiningNotes === true) {
|
||||
if (autoRemovalCondition.noPiningNotes === true) {
|
||||
condition = [...condition, ...piningNoteIds];
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user