From 050787238babfb28985d6eeeac86bcd2e013abee Mon Sep 17 00:00:00 2001 From: syuilo Date: Wed, 22 Mar 2023 18:45:55 +0900 Subject: [PATCH] =?UTF-8?q?fix(backend):=20=E7=B5=B5=E6=96=87=E5=AD=97?= =?UTF-8?q?=E3=82=92=E7=B7=A8=E9=9B=86=E3=81=99=E3=82=8B=E3=81=A8=E4=BF=9D?= =?UTF-8?q?=E5=AD=98=E3=81=A7=E3=81=8D=E3=81=AA=E3=81=84=E3=81=93=E3=81=A8?= =?UTF-8?q?=E3=81=8C=E3=81=82=E3=82=8B=E5=95=8F=E9=A1=8C=E3=82=92=E4=BF=AE?= =?UTF-8?q?=E6=AD=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Fix #10384 --- CHANGELOG.md | 3 +++ .../src/server/api/endpoints/admin/emoji/update.ts | 12 ++++++------ 2 files changed, 9 insertions(+), 6 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 8a2a2bfe78..36996e9699 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -14,6 +14,9 @@ ## 13.10.2 +### Server +- 絵文字を編集すると保存できないことがある問題を修正 + ### Client - ドライブファイルのメニューが正常に動作しない問題を修正 diff --git a/packages/backend/src/server/api/endpoints/admin/emoji/update.ts b/packages/backend/src/server/api/endpoints/admin/emoji/update.ts index 1c649db93e..bc0475e05c 100644 --- a/packages/backend/src/server/api/endpoints/admin/emoji/update.ts +++ b/packages/backend/src/server/api/endpoints/admin/emoji/update.ts @@ -1,5 +1,5 @@ import { Inject, Injectable } from '@nestjs/common'; -import { DataSource } from 'typeorm'; +import { DataSource, IsNull } from 'typeorm'; import { Endpoint } from '@/server/api/endpoint-base.js'; import type { EmojisRepository } from '@/models/index.js'; import { DI } from '@/di-symbols.js'; @@ -19,9 +19,9 @@ export const meta = { code: 'NO_SUCH_EMOJI', id: '684dec9d-a8c2-4364-9aa8-456c49cb1dc8', }, - alreadyexistsemoji: { - message: 'Emoji already exists', - code: 'EMOJI_ALREADY_EXISTS', + sameNameEmojiExists: { + message: 'Emoji that have same name already exists.', + code: 'SAME_NAME_EMOJI_EXISTS', id: '7180fe9d-1ee3-bff9-647d-fe9896d2ffb8', }, }, @@ -62,9 +62,9 @@ export default class extends Endpoint { ) { super(meta, paramDef, async (ps, me) => { const emoji = await this.emojisRepository.findOneBy({ id: ps.id }); - const emojiname = await this.emojisRepository.findOneBy({ name: ps.name }); + const sameNameEmoji = await this.emojisRepository.findOneBy({ name: ps.name, host: IsNull() }); if (emoji == null) throw new ApiError(meta.errors.noSuchEmoji); - if (emojiname != null && emojiname.id !== ps.id) throw new ApiError(meta.errors.alreadyexistsemoji); + if (sameNameEmoji != null && sameNameEmoji.id !== ps.id) throw new ApiError(meta.errors.sameNameEmojiExists); await this.emojisRepository.update(emoji.id, { updatedAt: new Date(), name: ps.name,