mirror of
https://codeberg.org/yeentown/barkey.git
synced 2025-04-28 09:36:56 +00:00
delete scheduled notes when deleting account - fixes #936
This commit is contained in:
parent
c6cabb8c75
commit
acf1b661a2
1 changed files with 22 additions and 1 deletions
|
@ -6,7 +6,7 @@
|
|||
import { Inject, Injectable } from '@nestjs/common';
|
||||
import { MoreThan } from 'typeorm';
|
||||
import { DI } from '@/di-symbols.js';
|
||||
import type { DriveFilesRepository, NoteReactionsRepository, NotesRepository, UserProfilesRepository, UsersRepository } from '@/models/_.js';
|
||||
import type { DriveFilesRepository, NoteReactionsRepository, NotesRepository, UserProfilesRepository, UsersRepository, NoteScheduleRepository, MiNoteSchedule } from '@/models/_.js';
|
||||
import type Logger from '@/logger.js';
|
||||
import { DriveService } from '@/core/DriveService.js';
|
||||
import type { MiDriveFile } from '@/models/DriveFile.js';
|
||||
|
@ -20,6 +20,7 @@ import { ReactionService } from '@/core/ReactionService.js';
|
|||
import { QueueLoggerService } from '../QueueLoggerService.js';
|
||||
import type * as Bull from 'bullmq';
|
||||
import type { DbUserDeleteJobData } from '../types.js';
|
||||
import { QueueService } from '@/core/QueueService.js';
|
||||
|
||||
@Injectable()
|
||||
export class DeleteAccountProcessorService {
|
||||
|
@ -41,6 +42,10 @@ export class DeleteAccountProcessorService {
|
|||
@Inject(DI.noteReactionsRepository)
|
||||
private noteReactionsRepository: NoteReactionsRepository,
|
||||
|
||||
@Inject(DI.noteScheduleRepository)
|
||||
private noteScheduleRepository: NoteScheduleRepository,
|
||||
|
||||
private queueService: QueueService,
|
||||
private driveService: DriveService,
|
||||
private emailService: EmailService,
|
||||
private queueLoggerService: QueueLoggerService,
|
||||
|
@ -60,6 +65,22 @@ export class DeleteAccountProcessorService {
|
|||
return;
|
||||
}
|
||||
|
||||
{ // Delete scheduled notes
|
||||
const scheduledNotes = await this.noteScheduleRepository.findBy({
|
||||
userId: user.id,
|
||||
}) as MiNoteSchedule[];
|
||||
|
||||
for (const note of scheduledNotes) {
|
||||
await this.queueService.ScheduleNotePostQueue.remove(`schedNote:${note.id}`);
|
||||
}
|
||||
|
||||
await this.noteScheduleRepository.delete({
|
||||
userId: user.id,
|
||||
});
|
||||
|
||||
this.logger.succ('All scheduled notes deleted');
|
||||
}
|
||||
|
||||
{ // Delete notes
|
||||
let cursor: MiNote['id'] | null = null;
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue