diff --git a/packages/backend/src/server/api/endpoints/flash/show.ts b/packages/backend/src/server/api/endpoints/flash/show.ts index 210a93edbd..14720a8c8d 100644 --- a/packages/backend/src/server/api/endpoints/flash/show.ts +++ b/packages/backend/src/server/api/endpoints/flash/show.ts @@ -1,11 +1,5 @@ -/* - * SPDX-FileCopyrightText: syuilo and other misskey contributors - * SPDX-License-Identifier: AGPL-3.0-only - */ - -import { IsNull } from 'typeorm'; import { Inject, Injectable } from '@nestjs/common'; -import type { UsersRepository, FlashsRepository, Flash } from '@/models/index.js'; +import type { UsersRepository, FlashsRepository } from '@/models/index.js'; import { Endpoint } from '@/server/api/endpoint-base.js'; import { FlashEntityService } from '@/core/entities/FlashEntityService.js'; import { DI } from '@/di-symbols.js'; @@ -35,39 +29,24 @@ export const paramDef = { type: 'object', properties: { flashId: { type: 'string', format: 'misskey:id' }, - username: { type: 'string' }, }, - anyOf: [ - { required: ['flashId'] }, - { required: ['username'] }, - ], + required: ['flashId'], } as const; // eslint-disable-next-line import/no-default-export @Injectable() export default class extends Endpoint { constructor( + @Inject(DI.usersRepository) + private usersRepository: UsersRepository, + @Inject(DI.flashsRepository) private flashsRepository: FlashsRepository, private flashEntityService: FlashEntityService, ) { super(meta, paramDef, async (ps, me) => { - let flash: Flash | null = null; - if (ps.flashId) { - flash = await this.flashsRepository.findOneBy({ id: ps.flashId }); - } - else if (ps.username) { - const author = await this.usersRepository.findOneBy({ - host: IsNull(), - usernameLower: ps.username.toLowerCase(), - }); - if (author) { - flash = await this.flashsRepository.findOneBy({ - userId: author.id, - }); - } - } + const flash = await this.flashsRepository.findOneBy({ id: ps.flashId }); if (flash == null) { throw new ApiError(meta.errors.noSuchFlash);