Update packages/backend/src/server/api/endpoints/admin/emoji/update.ts

Co-authored-by: syuilo <Syuilotan@yahoo.co.jp>
This commit is contained in:
nenohi 2023-10-06 13:46:55 +09:00 committed by GitHub
parent 10794eaa90
commit 1692c188bd
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 5 additions and 5 deletions

View File

@ -74,11 +74,11 @@ export default class extends Endpoint<typeof meta, typeof paramDef> { // eslint-
driveFile = await this.driveFilesRepository.findOneBy({ id: ps.fileId });
if (driveFile == null) throw new ApiError(meta.errors.noSuchFile);
}
const oldemoji = await this.customEmojiService.getEmojiById(ps.id);
if (oldemoji !== null) {
if (ps.name !== oldemoji.name) {
const duplicateCheck = await this.customEmojiService.isDuplicateCheck(ps.name);
if (duplicateCheck) throw new ApiError(meta.errors.sameNameEmojiExists);
const emoji = await this.customEmojiService.getEmojiById(ps.id);
if (emoji != null) {
if (ps.name !== emoji.name) {
const isDuplicate = await this.customEmojiService.checkDuplicate(ps.name);
if (isDuplicate) throw new ApiError(meta.errors.sameNameEmojiExists);
}
} else {
throw new ApiError(meta.errors.noSuchEmoji);