From 21677aa30d3b45aebea83b2392e2fc6960ac1bb0 Mon Sep 17 00:00:00 2001 From: Namekuji Date: Sat, 15 Apr 2023 05:30:39 -0400 Subject: [PATCH] prohibit moved account from moving again --- packages/backend/src/server/api/endpoints/i/known-as.ts | 5 ++--- packages/backend/src/server/api/endpoints/i/move.ts | 1 + 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/packages/backend/src/server/api/endpoints/i/known-as.ts b/packages/backend/src/server/api/endpoints/i/known-as.ts index 7aa401e9bb..dc96e5e2eb 100644 --- a/packages/backend/src/server/api/endpoints/i/known-as.ts +++ b/packages/backend/src/server/api/endpoints/i/known-as.ts @@ -7,7 +7,6 @@ import { ApiError } from '@/server/api/error.js'; import { AccountMoveService } from '@/core/AccountMoveService.js'; import { RemoteUserResolveService } from '@/core/RemoteUserResolveService.js'; -import { UserEntityService } from '@/core/entities/UserEntityService.js'; import { ApiLoggerService } from '@/server/api/ApiLoggerService.js'; export const meta = { @@ -15,6 +14,7 @@ export const meta = { secure: true, requireCredential: true, + prohibitMoved: true, limit: { duration: ms('1day'), @@ -46,7 +46,6 @@ export const paramDef = { @Injectable() export default class extends Endpoint { constructor( - private userEntityService: UserEntityService, private remoteUserResolveService: RemoteUserResolveService, private apiLoggerService: ApiLoggerService, private accountMoveService: AccountMoveService, @@ -76,7 +75,7 @@ export default class extends Endpoint { const toUrl = this.accountMoveService.getUserUri(knownAs); if (!toUrl) throw new ApiError(meta.errors.uriNull); - updates.alsoKnownAs = updates.alsoKnownAs?.concat([toUrl]) ?? [toUrl]; + updates.alsoKnownAs = me.alsoKnownAs?.includes(toUrl) ? me.alsoKnownAs : me.alsoKnownAs?.concat([toUrl]) ?? [toUrl]; } return await this.accountMoveService.createAlias(me, updates); diff --git a/packages/backend/src/server/api/endpoints/i/move.ts b/packages/backend/src/server/api/endpoints/i/move.ts index 972dd6076d..a13e6cda41 100644 --- a/packages/backend/src/server/api/endpoints/i/move.ts +++ b/packages/backend/src/server/api/endpoints/i/move.ts @@ -19,6 +19,7 @@ export const meta = { secure: true, requireCredential: true, + prohibitMoved: true, limit: { duration: ms('1day'), max: 5,