From ce54e810a33e452f5fbac4c75ce5c367b5d2490a Mon Sep 17 00:00:00 2001 From: anatawa12 Date: Sun, 3 Aug 2025 20:52:05 +0900 Subject: [PATCH] =?UTF-8?q?chore:=20=E3=83=AA=E3=83=8E=E3=83=BC=E3=83=88?= =?UTF-8?q?=E3=81=A7=E3=82=82=E3=81=AA=E3=81=8F=E3=80=81=E3=83=AA=E3=83=97?= =?UTF-8?q?=E3=83=A9=E3=82=A4=E3=81=A7=E3=82=82=E3=81=AA=E3=81=8F=E3=80=81?= =?UTF-8?q?=E3=83=AA=E3=83=97=E3=83=A9=E3=82=A4=E3=82=82=E8=87=AA=E5=B7=B1?= =?UTF-8?q?=E3=83=AA=E3=83=8E=E3=83=BC=E3=83=88=E3=82=82=E3=81=AA=E3=81=84?= =?UTF-8?q?=E3=83=8E=E3=83=BC=E3=83=88=E3=81=AB=E3=81=A4=E3=81=84=E3=81=A6?= =?UTF-8?q?=E3=81=AF=20CleanRemoteNotesProcessor=20=E3=81=A7=20deleted=5Fn?= =?UTF-8?q?ote=20=E4=BA=8C=E8=BF=BD=E5=8A=A0=E3=81=97=E3=81=AA=E3=81=84?= =?UTF-8?q?=E3=82=88=E3=81=86=E3=81=AB?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../CleanRemoteNotesProcessorService.ts | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) diff --git a/packages/backend/src/queue/processors/CleanRemoteNotesProcessorService.ts b/packages/backend/src/queue/processors/CleanRemoteNotesProcessorService.ts index 9436b1a1ca..019cbc47a3 100644 --- a/packages/backend/src/queue/processors/CleanRemoteNotesProcessorService.ts +++ b/packages/backend/src/queue/processors/CleanRemoteNotesProcessorService.ts @@ -138,18 +138,29 @@ export class CleanRemoteNotesProcessorService { const replies = notes.length === 0 ? [] : await this.notesRepository.find({ where: { replyId: In(notes.map(note => note.id)), - userHost: IsNull(), }, - select: ['replyId'], + select: ['replyId', 'userHost'], }); + const noteIdsWithReplies = new Set(replies.map(reply => reply.replyId)); + notes = notes.filter(note => { - return !replies.some(reply => reply.replyId === note.id); + return !replies.some(reply => reply.userHost == null && reply.replyId === note.id); }); + // find self renotes and quotes to determine if we should keep deleted notes + const renotes = notes.length === 0 ? [] : await this.notesRepository.find({ + where: { + renoteId: In(notes.map(note => note.id)), + }, + select: ['renoteId'], + }); + + const noteIdsWithRenotes = new Set(renotes.map(reply => reply.replyId)); + if (notes.length > 0) { await this.db.transaction(async (transaction) => { - await transaction.save(MiDeletedNote, notes.map(note => ({ + await transaction.save(MiDeletedNote, notes.filter(x => x.replyId != null || x.renoteId != null || noteIdsWithReplies.has(x.id) || noteIdsWithRenotes.has(x.id)).map(note => ({ id: note.id, deletedAt: null, // This is existing note on the remote, so we set deletedAt to null. replyId: note.replyId,