From 4d6ff822c4ca0b49d5447e1aa61f63bdf9972916 Mon Sep 17 00:00:00 2001 From: syuilo <4439005+syuilo@users.noreply.github.com> Date: Wed, 17 Sep 2025 19:58:18 +0900 Subject: [PATCH] Update show.ts --- .../src/server/api/endpoints/ap/show.ts | 37 +------------------ 1 file changed, 2 insertions(+), 35 deletions(-) diff --git a/packages/backend/src/server/api/endpoints/ap/show.ts b/packages/backend/src/server/api/endpoints/ap/show.ts index 1fd5d0c0fb..fe48e7497a 100644 --- a/packages/backend/src/server/api/endpoints/ap/show.ts +++ b/packages/backend/src/server/api/endpoints/ap/show.ts @@ -18,13 +18,9 @@ import { UserEntityService } from '@/core/entities/UserEntityService.js'; import { NoteEntityService } from '@/core/entities/NoteEntityService.js'; import { UtilityService } from '@/core/UtilityService.js'; import { bindThis } from '@/decorators.js'; -import { ApiError } from '../../error.js'; import { IdentifiableError } from '@/misc/identifiable-error.js'; import { FetchAllowSoftFailMask } from '@/core/activitypub/misc/check-against-url.js'; -import * as Acct from '@/misc/acct.js'; -import { IsNull } from 'typeorm'; -import { DI } from '@/di-symbols.js'; -import type { NotesRepository, UsersRepository } from '@/models/_.js'; +import { ApiError } from '../../error.js'; export const meta = { tags: ['federation'], @@ -113,9 +109,6 @@ export const paramDef = { @Injectable() export default class extends Endpoint { // eslint-disable-line import/no-default-export constructor( - @Inject(DI.usersRepository) - private usersRepository: UsersRepository, - private utilityService: UtilityService, private userEntityService: UserEntityService, private noteEntityService: NoteEntityService, @@ -144,7 +137,7 @@ export default class extends Endpoint { // eslint- } let local = await this.mergePack(me, ...await Promise.all([ - this.apDbResolverService.getUserFromApId(uri).then(async x => x ?? await this.getUserFromProfileUrl(uri)), + this.apDbResolverService.getUserFromApId(uri), this.apDbResolverService.getNoteFromApId(uri), ])); if (local != null) return local; @@ -207,32 +200,6 @@ export default class extends Endpoint { // eslint- ); } - // To keep consistency with ap/show from external server, - // this function will handle `https://local.instance/@user` - // profile url to resolve user. - @bindThis - private async getUserFromProfileUrl(url: string): Promise { - if (!this.utilityService.isUriLocal(url)) { - return null; - } - - const uri = new URL(url); - const pathComponents = uri.pathname.split('/').filter(Boolean); - if (pathComponents.length === 1 && pathComponents[0].startsWith('@')) { - const acct = Acct.parse(pathComponents[0]); - // normalize acct host - if (this.utilityService.isSelfHost(acct.host)) acct.host = null; - - return await this.usersRepository.findOneBy({ - usernameLower: acct.username.toLowerCase(), - host: acct.host ?? IsNull(), - isSuspended: false, - }); - } - - return null; - } - @bindThis private async mergePack(me: MiLocalUser | null | undefined, user: MiUser | null | undefined, note: MiNote | null | undefined): Promise | null> { if (user != null) {