fix: 絵文字重複周りの修正

This commit is contained in:
mattyatea 2023-09-17 17:08:03 +09:00
parent 272c5a1dfe
commit 3a20dfb245
2 changed files with 22 additions and 4 deletions

View File

@ -73,15 +73,19 @@ export default class extends Endpoint<typeof meta, typeof paramDef> { // eslint-
const driveFile = await this.driveFilesRepository.findOneBy({ id: ps.fileId });
if (driveFile == null) throw new ApiError(meta.errors.noSuchFile);
const existEmoji = await this.emojisRepository.exist({
const duplicationEmoji = await this.emojisRepository.find({
where: {
name: ps.name,
},
});
if (existEmoji) {
throw new ApiError(meta.errors.duplicationEmojiAdd);
}
duplicationEmoji.forEach(
(emoji) => {
if (emoji.name === ps.name) {
throw new ApiError(meta.errors.duplicationEmojiAdd);
}
}
)
const emoji = await this.customEmojiService.add({
driveFile,

View File

@ -75,6 +75,20 @@ export default class extends Endpoint<typeof meta, typeof paramDef> { // eslint-
throw new ApiError(meta.errors.noSuchEmoji);
}
const duplicationEmoji = await this.emojisRepository.find({
where: {
name: emoji.name,
},
});
duplicationEmoji.forEach(
(_emoji) => {
if (_emoji.name === emoji.name) {
throw new ApiError(meta.errors.duplicationEmojiAdd);
}
}
)
let driveFile: MiDriveFile;
try {