From 4d0e930c0c8a6769a829d6666cec1f67cb7071af Mon Sep 17 00:00:00 2001 From: GrapeApple0 <84321396+GrapeApple0@users.noreply.github.com> Date: Sun, 20 Aug 2023 07:22:25 +0000 Subject: [PATCH] =?UTF-8?q?=E9=96=93=E9=81=95=E3=81=88=E3=81=A6=E5=A4=89?= =?UTF-8?q?=E6=9B=B4=E3=81=97=E3=81=A6=E3=81=97=E3=81=BE=E3=81=A3=E3=81=9F?= =?UTF-8?q?=E3=81=AE=E3=82=92=E4=BF=AE=E6=AD=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/server/api/endpoints/flash/show.ts | 33 ++++--------------- 1 file changed, 6 insertions(+), 27 deletions(-) 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);