diff options
| author | Hazelnoot <acomputerdog@gmail.com> | 2025-05-10 23:21:04 -0400 |
|---|---|---|
| committer | Hazelnoot <acomputerdog@gmail.com> | 2025-05-12 21:38:10 -0400 |
| commit | 7ad772116b8d7364c8a42e07e0d75d994e65230b (patch) | |
| tree | e00a09f9fc6764614e7f3007422e7db0590b82c3 /packages/backend/src | |
| parent | merge: Add "is from local bubble instance" role condition (!1011) (diff) | |
| download | sharkey-7ad772116b8d7364c8a42e07e0d75d994e65230b.tar.gz sharkey-7ad772116b8d7364c8a42e07e0d75d994e65230b.tar.bz2 sharkey-7ad772116b8d7364c8a42e07e0d75d994e65230b.zip | |
delete user reactions before notes
Diffstat (limited to 'packages/backend/src')
| -rw-r--r-- | packages/backend/src/queue/processors/DeleteAccountProcessorService.ts | 62 |
1 files changed, 31 insertions, 31 deletions
diff --git a/packages/backend/src/queue/processors/DeleteAccountProcessorService.ts b/packages/backend/src/queue/processors/DeleteAccountProcessorService.ts index 46cee096cf..8922370104 100644 --- a/packages/backend/src/queue/processors/DeleteAccountProcessorService.ts +++ b/packages/backend/src/queue/processors/DeleteAccountProcessorService.ts @@ -65,6 +65,37 @@ export class DeleteAccountProcessorService { return; } + { // Delete reactions + let cursor: MiNoteReaction['id'] | null = null; + + while (true) { + const reactions = await this.noteReactionsRepository.find({ + where: { + userId: user.id, + ...(cursor ? { id: MoreThan(cursor) } : {}), + }, + take: 100, + order: { + id: 1, + }, + }) as MiNoteReaction[]; + + if (reactions.length === 0) { + break; + } + + cursor = reactions.at(-1)?.id ?? null; + + for (const reaction of reactions) { + const note = await this.notesRepository.findOneBy({ id: reaction.noteId }) as MiNote; + + await this.reactionService.delete(user, note); + } + } + + this.logger.succ('All reactions have been deleted'); + } + { // Delete scheduled notes const scheduledNotes = await this.noteScheduleRepository.findBy({ userId: user.id, @@ -119,37 +150,6 @@ export class DeleteAccountProcessorService { this.logger.succ('All of notes deleted'); } - { // Delete reactions - let cursor: MiNoteReaction['id'] | null = null; - - while (true) { - const reactions = await this.noteReactionsRepository.find({ - where: { - userId: user.id, - ...(cursor ? { id: MoreThan(cursor) } : {}), - }, - take: 100, - order: { - id: 1, - }, - }) as MiNoteReaction[]; - - if (reactions.length === 0) { - break; - } - - cursor = reactions.at(-1)?.id ?? null; - - for (const reaction of reactions) { - const note = await this.notesRepository.findOneBy({ id: reaction.noteId }) as MiNote; - - await this.reactionService.delete(user, note); - } - } - - this.logger.succ('All reactions have been deleted'); - } - { // Delete files let cursor: MiDriveFile['id'] | null = null; |