間違えて変更してしまったのを修正
This commit is contained in:
parent
cbbc7753ea
commit
4d0e930c0c
|
|
@ -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 { 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 { Endpoint } from '@/server/api/endpoint-base.js';
|
||||||
import { FlashEntityService } from '@/core/entities/FlashEntityService.js';
|
import { FlashEntityService } from '@/core/entities/FlashEntityService.js';
|
||||||
import { DI } from '@/di-symbols.js';
|
import { DI } from '@/di-symbols.js';
|
||||||
|
|
@ -35,39 +29,24 @@ export const paramDef = {
|
||||||
type: 'object',
|
type: 'object',
|
||||||
properties: {
|
properties: {
|
||||||
flashId: { type: 'string', format: 'misskey:id' },
|
flashId: { type: 'string', format: 'misskey:id' },
|
||||||
username: { type: 'string' },
|
|
||||||
},
|
},
|
||||||
anyOf: [
|
required: ['flashId'],
|
||||||
{ required: ['flashId'] },
|
|
||||||
{ required: ['username'] },
|
|
||||||
],
|
|
||||||
} as const;
|
} as const;
|
||||||
|
|
||||||
// eslint-disable-next-line import/no-default-export
|
// eslint-disable-next-line import/no-default-export
|
||||||
@Injectable()
|
@Injectable()
|
||||||
export default class extends Endpoint<typeof meta, typeof paramDef> {
|
export default class extends Endpoint<typeof meta, typeof paramDef> {
|
||||||
constructor(
|
constructor(
|
||||||
|
@Inject(DI.usersRepository)
|
||||||
|
private usersRepository: UsersRepository,
|
||||||
|
|
||||||
@Inject(DI.flashsRepository)
|
@Inject(DI.flashsRepository)
|
||||||
private flashsRepository: FlashsRepository,
|
private flashsRepository: FlashsRepository,
|
||||||
|
|
||||||
private flashEntityService: FlashEntityService,
|
private flashEntityService: FlashEntityService,
|
||||||
) {
|
) {
|
||||||
super(meta, paramDef, async (ps, me) => {
|
super(meta, paramDef, async (ps, me) => {
|
||||||
let flash: Flash | null = null;
|
const flash = await this.flashsRepository.findOneBy({ id: ps.flashId });
|
||||||
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,
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (flash == null) {
|
if (flash == null) {
|
||||||
throw new ApiError(meta.errors.noSuchFlash);
|
throw new ApiError(meta.errors.noSuchFlash);
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue