1
0
forked from mirror/misskey

絵文字の名前に@や:が使用できる (#9964)

* fix(#9918)名前の一致でもエラーとするように

* 判定を逆に

* )の位置間違えてる

* カテゴリ分けとかしたときにエラーになる

* エラー消し

* こういうこと・・・?
This commit is contained in:
nenohi 2023-03-20 14:24:18 +09:00 committed by GitHub
parent 3d6aaa7aaa
commit e152047912
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -19,6 +19,11 @@ export const meta = {
code: 'NO_SUCH_EMOJI', code: 'NO_SUCH_EMOJI',
id: '684dec9d-a8c2-4364-9aa8-456c49cb1dc8', id: '684dec9d-a8c2-4364-9aa8-456c49cb1dc8',
}, },
alreadyexistsemoji: {
message: 'Emoji already exists',
code: 'EMOJI_ALREADY_EXISTS',
id: '7180fe9d-1ee3-bff9-647d-fe9896d2ffb8',
},
}, },
} as const; } as const;
@ -26,7 +31,7 @@ export const paramDef = {
type: 'object', type: 'object',
properties: { properties: {
id: { type: 'string', format: 'misskey:id' }, id: { type: 'string', format: 'misskey:id' },
name: { type: 'string' }, name: { type: 'string', pattern: '^[a-zA-Z0-9_]+$' },
category: { category: {
type: 'string', type: 'string',
nullable: true, nullable: true,
@ -57,9 +62,9 @@ export default class extends Endpoint<typeof meta, typeof paramDef> {
) { ) {
super(meta, paramDef, async (ps, me) => { super(meta, paramDef, async (ps, me) => {
const emoji = await this.emojisRepository.findOneBy({ id: ps.id }); const emoji = await this.emojisRepository.findOneBy({ id: ps.id });
const emojiname = await this.emojisRepository.findOneBy({ name: ps.name });
if (emoji == null) throw new ApiError(meta.errors.noSuchEmoji); if (emoji == null) throw new ApiError(meta.errors.noSuchEmoji);
if (emojiname != null && emojiname.id !== ps.id) throw new ApiError(meta.errors.alreadyexistsemoji);
await this.emojisRepository.update(emoji.id, { await this.emojisRepository.update(emoji.id, {
updatedAt: new Date(), updatedAt: new Date(),
name: ps.name, name: ps.name,