間違えて変更してしまったのを修正

This commit is contained in:
GrapeApple0 2023-08-20 07:22:25 +00:00
parent cbbc7753ea
commit 4d0e930c0c
1 changed files with 6 additions and 27 deletions

View File

@ -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<typeof meta, typeof paramDef> {
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);