type fix
This commit is contained in:
parent
77ae12bf18
commit
f965b35a2c
|
@ -114,20 +114,20 @@ export class CustomEmojiService implements OnApplicationShutdown {
|
|||
localOnly?: boolean;
|
||||
roleIdsThatCanBeUsedThisEmojiAsReaction?: MiRole['id'][];
|
||||
}, moderator?: MiUser): Promise<
|
||||
undefined
|
||||
void
|
||||
| "NO_SUCH_EMOJI"
|
||||
| "SAME_NAME_EMOJI_EXISTS"
|
||||
> {
|
||||
const emoji = data.id
|
||||
? await this.getEmojiById(data.id)
|
||||
: await this.getEmojiByName(data.name);
|
||||
: await this.getEmojiByName(data.name!);
|
||||
if (emoji === null) return "NO_SUCH_EMOJI";
|
||||
const id = emoji.id;
|
||||
|
||||
// IDと絵文字名が両方指定されている場合は絵文字名の変更を行うため重複チェックが必要
|
||||
const doNameUpdate = data.id && data.name && (data.name !== emoji.name);
|
||||
if (doNameUpdate) {
|
||||
const isDuplicate = await this.checkDuplicate(data.name);
|
||||
const isDuplicate = await this.checkDuplicate(data.name!);
|
||||
if (isDuplicate) return "SAME_NAME_EMOJI_EXISTS";
|
||||
}
|
||||
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
import { Inject, Injectable } from '@nestjs/common';
|
||||
import { Endpoint } from '@/server/api/endpoint-base.js';
|
||||
import { CustomEmojiService } from '@/core/CustomEmojiService.js';
|
||||
import type { DriveFilesRepository } from '@/models/_.js';
|
||||
import type { DriveFilesRepository, MiEmoji } from '@/models/_.js';
|
||||
import { DI } from '@/di-symbols.js';
|
||||
import { ApiError } from '../../../error.js';
|
||||
|
||||
|
@ -78,9 +78,13 @@ export default class extends Endpoint<typeof meta, typeof paramDef> { // eslint-
|
|||
if (driveFile == null) throw new ApiError(meta.errors.noSuchFile);
|
||||
}
|
||||
|
||||
// JSON schemeのanyOfの型変換がうまくいっていないらしい
|
||||
const required = { id: ps.id, name: ps.name } as
|
||||
| { id: MiEmoji['id']; name?: string }
|
||||
| { id?: MiEmoji['id']; name: string };
|
||||
|
||||
const error = await this.customEmojiService.update({
|
||||
id: ps.id,
|
||||
name: ps.name,
|
||||
...required,
|
||||
driveFile,
|
||||
category: ps.category,
|
||||
aliases: ps.aliases,
|
||||
|
|
Loading…
Reference in New Issue