From 688e1fdb775a4ae8b238420ad2e4be5370e7d647 Mon Sep 17 00:00:00 2001 From: anatawa12 Date: Sat, 28 Oct 2023 17:53:52 +0900 Subject: [PATCH] chore: make pure renote detection an function --- .../backend/src/server/api/endpoints/notes/create.ts | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/packages/backend/src/server/api/endpoints/notes/create.ts b/packages/backend/src/server/api/endpoints/notes/create.ts index 3ae4ac044a..e307aa0302 100644 --- a/packages/backend/src/server/api/endpoints/notes/create.ts +++ b/packages/backend/src/server/api/endpoints/notes/create.ts @@ -214,14 +214,19 @@ export default class extends Endpoint { // eslint- } } + function isPureRenote(note: MiNote): boolean { + return !!(note.renoteId && !note.text && !note.fileIds && !note.hasPoll); + } + let renote: MiNote | null = null; if (ps.renoteId != null) { // Fetch renote to note renote = await this.notesRepository.findOneBy({ id: ps.renoteId }); + console.log("renote", renote); if (renote == null) { throw new ApiError(meta.errors.noSuchRenoteTarget); - } else if (renote.renoteId && !renote.text && !renote.fileIds && !renote.hasPoll) { + } else if (isPureRenote(renote)) { throw new ApiError(meta.errors.cannotReRenote); } @@ -254,7 +259,7 @@ export default class extends Endpoint { // eslint- if (reply == null) { throw new ApiError(meta.errors.noSuchReplyTarget); - } else if (reply.renoteId && !reply.text && !reply.fileIds && !reply.hasPoll) { + } else if (isPureRenote(reply)) { throw new ApiError(meta.errors.cannotReplyToPureRenote); }