From 9292cde76a82ea992d774b769b647ad87288fcca Mon Sep 17 00:00:00 2001 From: Namekuji Date: Thu, 20 Apr 2023 22:55:25 -0400 Subject: [PATCH] skip to add to alsoKnownAs if toUrl is known --- packages/backend/src/core/AccountMoveService.ts | 10 +++------- packages/backend/src/server/api/endpoints/i/update.ts | 6 +++--- 2 files changed, 6 insertions(+), 10 deletions(-) diff --git a/packages/backend/src/core/AccountMoveService.ts b/packages/backend/src/core/AccountMoveService.ts index 6c04154a30..aace2d2bd7 100644 --- a/packages/backend/src/core/AccountMoveService.ts +++ b/packages/backend/src/core/AccountMoveService.ts @@ -10,11 +10,9 @@ import type { RelationshipJobData, ThinUser } from '@/queue/types.js'; import type { User } from '@/models/entities/User.js'; import { IdService } from '@/core/IdService.js'; -import { AccountUpdateService } from '@/core/AccountUpdateService.js'; import { GlobalEventService } from '@/core/GlobalEventService.js'; import { QueueService } from '@/core/QueueService.js'; import { RelayService } from '@/core/RelayService.js'; -import { UserFollowingService } from '@/core/UserFollowingService.js'; import { ApDeliverManagerService } from '@/core/activitypub/ApDeliverManagerService.js'; import { ApRendererService } from '@/core/activitypub/ApRendererService.js'; import { UserEntityService } from '@/core/entities/UserEntityService.js'; @@ -54,8 +52,6 @@ export class AccountMoveService { private apRendererService: ApRendererService, private apDeliverManagerService: ApDeliverManagerService, private globalEventService: GlobalEventService, - private userFollowingService: UserFollowingService, - private accountUpdateService: AccountUpdateService, private proxyAccountService: ProxyAccountService, private perUserFollowingChart: PerUserFollowingChart, private federatedInstanceService: FederatedInstanceService, @@ -193,7 +189,7 @@ export class AccountMoveService { const newJoinings: Map = new Map(); // 重複しないようにIDを生成 - const genId = () => { + const genId = (): string => { let id: string; do { id = this.idService.genId(); @@ -222,8 +218,8 @@ export class AccountMoveService { @bindThis public getUserUri(user: User): string { - return this.userEntityService.isRemoteUser(user) - ? user.uri : `${this.config.url}/users/${user.id}`; + return this.userEntityService.isRemoteUser(user) + ? user.uri : `${this.config.url}/users/${user.id}`; } @bindThis diff --git a/packages/backend/src/server/api/endpoints/i/update.ts b/packages/backend/src/server/api/endpoints/i/update.ts index e59b759b58..5971791874 100644 --- a/packages/backend/src/server/api/endpoints/i/update.ts +++ b/packages/backend/src/server/api/endpoints/i/update.ts @@ -301,7 +301,7 @@ export default class extends Endpoint { } // Parse user's input into the old account - const newAlsoKnownAs: string[] = []; + const newAlsoKnownAs = new Set(); for (const line of ps.alsoKnownAs) { let unfiltered = line; if (unfiltered.startsWith('acct:')) unfiltered = unfiltered.substring(5); @@ -319,10 +319,10 @@ export default class extends Endpoint { const toUrl = this.accountMoveService.getUserUri(knownAs); if (!toUrl) throw new ApiError(meta.errors.uriNull); - newAlsoKnownAs.push(toUrl); + newAlsoKnownAs.add(toUrl); } - updates.alsoKnownAs = newAlsoKnownAs.length > 0 ? newAlsoKnownAs : null; + updates.alsoKnownAs = newAlsoKnownAs.size > 0 ? Array.from(newAlsoKnownAs) : null; } //#region emojis/tags