diff --git a/packages/backend/src/server/api/endpoints/admin/emoji/copy.ts b/packages/backend/src/server/api/endpoints/admin/emoji/copy.ts index a65e4e762..9348e279f 100644 --- a/packages/backend/src/server/api/endpoints/admin/emoji/copy.ts +++ b/packages/backend/src/server/api/endpoints/admin/emoji/copy.ts @@ -4,6 +4,7 @@ */ import { Inject, Injectable } from '@nestjs/common'; +import { IsNull } from 'typeorm'; import { Endpoint } from '@/server/api/endpoint-base.js'; import type { EmojisRepository } from '@/models/_.js'; import { IdService } from '@/core/IdService.js'; @@ -26,6 +27,11 @@ export const meta = { code: 'NO_SUCH_EMOJI', id: 'e2785b66-dca3-4087-9cac-b93c541cc425', }, + duplicateName: { + message: 'Duplicate name.', + code: 'DUPLICATE_NAME', + id: 'f7a3462c-4e6e-4069-8421-b9bd4f4c3975', + }, }, res: { @@ -69,6 +75,9 @@ export default class extends Endpoint { // eslint- throw new ApiError(meta.errors.noSuchEmoji); } + const isDuplicate = await this.emojisRepository.findOneBy({ name: emoji.name, host: IsNull() } ); + if (isDuplicate) throw new ApiError(meta.errors.duplicateName); + let driveFile: MiDriveFile; try {