mirror of
https://codeberg.org/yeentown/barkey.git
synced 2025-07-08 04:54:32 +00:00
delete user reactions before notes
This commit is contained in:
parent
00cfeca3d7
commit
7ad772116b
1 changed files with 31 additions and 31 deletions
|
@ -65,6 +65,37 @@ export class DeleteAccountProcessorService {
|
||||||
return;
|
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
|
{ // Delete scheduled notes
|
||||||
const scheduledNotes = await this.noteScheduleRepository.findBy({
|
const scheduledNotes = await this.noteScheduleRepository.findBy({
|
||||||
userId: user.id,
|
userId: user.id,
|
||||||
|
@ -119,37 +150,6 @@ export class DeleteAccountProcessorService {
|
||||||
this.logger.succ('All of notes deleted');
|
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
|
{ // Delete files
|
||||||
let cursor: MiDriveFile['id'] | null = null;
|
let cursor: MiDriveFile['id'] | null = null;
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue