From 37d5c2c79bec9ad5ac5dd4bfb9108fc949ffaa15 Mon Sep 17 00:00:00 2001 From: okayurisotto Date: Mon, 3 Jul 2023 20:31:12 +0900 Subject: [PATCH] =?UTF-8?q?refactor(`ApPersonService.ts`):=20=E5=8F=AF?= =?UTF-8?q?=E8=AA=AD=E6=80=A7=E3=81=AE=E4=BD=8E=E3=81=84=E4=B8=89=E9=A0=85?= =?UTF-8?q?=E6=BC=94=E7=AE=97=E5=AD=90=E3=82=92=E5=89=8A=E9=99=A4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 元の実装が悪いと判断し`null`かどうかの確認をより厳密に行うようにした。 --- .../core/activitypub/models/ApPersonService.ts | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/packages/backend/src/core/activitypub/models/ApPersonService.ts b/packages/backend/src/core/activitypub/models/ApPersonService.ts index 4d5c3c78a3..45f0d452eb 100644 --- a/packages/backend/src/core/activitypub/models/ApPersonService.ts +++ b/packages/backend/src/core/activitypub/models/ApPersonService.ts @@ -460,12 +460,23 @@ export class ApPersonService implements OnModuleInit { isExplorable: !!person.discoverable, } as Partial & Pick; - const moving = + const moving = ((): boolean => { // 移行先がない→ある - (!exist.movedToUri && updates.movedToUri) || + if ( + exist.movedToUri === null && + updates.movedToUri + ) return true; + // 移行先がある→別のもの - (exist.movedToUri !== updates.movedToUri && exist.movedToUri && updates.movedToUri); + if ( + exist.movedToUri !== null && + updates.movedToUri !== null && + exist.movedToUri !== updates.movedToUri + ) return true; + // 移行先がある→ない、ない→ないは無視 + return false; + })(); if (moving) updates.movedAt = new Date();