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