skip to add to alsoKnownAs if toUrl is known

This commit is contained in:
Namekuji 2023-04-20 22:55:25 -04:00
parent e94e702429
commit 9292cde76a
2 changed files with 6 additions and 10 deletions

View file

@ -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<string, { createdAt: Date; userId: string; userListId: string; }> = 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

View file

@ -301,7 +301,7 @@ export default class extends Endpoint<typeof meta, typeof paramDef> {
}
// Parse user's input into the old account
const newAlsoKnownAs: string[] = [];
const newAlsoKnownAs = new Set<string>();
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<typeof meta, typeof paramDef> {
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