" -> '
This commit is contained in:
parent
f965b35a2c
commit
70bb365cd1
|
@ -115,20 +115,20 @@ export class CustomEmojiService implements OnApplicationShutdown {
|
||||||
roleIdsThatCanBeUsedThisEmojiAsReaction?: MiRole['id'][];
|
roleIdsThatCanBeUsedThisEmojiAsReaction?: MiRole['id'][];
|
||||||
}, moderator?: MiUser): Promise<
|
}, moderator?: MiUser): Promise<
|
||||||
void
|
void
|
||||||
| "NO_SUCH_EMOJI"
|
| 'NO_SUCH_EMOJI'
|
||||||
| "SAME_NAME_EMOJI_EXISTS"
|
| 'SAME_NAME_EMOJI_EXISTS'
|
||||||
> {
|
> {
|
||||||
const emoji = data.id
|
const emoji = data.id
|
||||||
? await this.getEmojiById(data.id)
|
? await this.getEmojiById(data.id)
|
||||||
: await this.getEmojiByName(data.name!);
|
: await this.getEmojiByName(data.name!);
|
||||||
if (emoji === null) return "NO_SUCH_EMOJI";
|
if (emoji === null) return 'NO_SUCH_EMOJI';
|
||||||
const id = emoji.id;
|
const id = emoji.id;
|
||||||
|
|
||||||
// IDと絵文字名が両方指定されている場合は絵文字名の変更を行うため重複チェックが必要
|
// IDと絵文字名が両方指定されている場合は絵文字名の変更を行うため重複チェックが必要
|
||||||
const doNameUpdate = data.id && data.name && (data.name !== emoji.name);
|
const doNameUpdate = data.id && data.name && (data.name !== emoji.name);
|
||||||
if (doNameUpdate) {
|
if (doNameUpdate) {
|
||||||
const isDuplicate = await this.checkDuplicate(data.name!);
|
const isDuplicate = await this.checkDuplicate(data.name!);
|
||||||
if (isDuplicate) return "SAME_NAME_EMOJI_EXISTS";
|
if (isDuplicate) return 'SAME_NAME_EMOJI_EXISTS';
|
||||||
}
|
}
|
||||||
|
|
||||||
await this.emojisRepository.update(emoji.id, {
|
await this.emojisRepository.update(emoji.id, {
|
||||||
|
|
|
@ -96,8 +96,8 @@ export default class extends Endpoint<typeof meta, typeof paramDef> { // eslint-
|
||||||
|
|
||||||
switch (error) {
|
switch (error) {
|
||||||
case undefined: return;
|
case undefined: return;
|
||||||
case "NO_SUCH_EMOJI": throw new ApiError(meta.errors.noSuchEmoji);
|
case 'NO_SUCH_EMOJI': throw new ApiError(meta.errors.noSuchEmoji);
|
||||||
case "SAME_NAME_EMOJI_EXISTS": throw new ApiError(meta.errors.sameNameEmojiExists);
|
case 'SAME_NAME_EMOJI_EXISTS': throw new ApiError(meta.errors.sameNameEmojiExists);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue