From b1df1a4c3b905ef3343fe48f0b0109df51458d02 Mon Sep 17 00:00:00 2001
From: FLY_MC <me@flymc.cc>
Date: Wed, 12 Mar 2025 01:26:19 +0800
Subject: [PATCH] backend: lint CustomEmojiService

---
 .../backend/src/core/CustomEmojiService.ts    | 30 ++++++++++---------
 1 file changed, 16 insertions(+), 14 deletions(-)

diff --git a/packages/backend/src/core/CustomEmojiService.ts b/packages/backend/src/core/CustomEmojiService.ts
index da71a5de6f..0fe2d35464 100644
--- a/packages/backend/src/core/CustomEmojiService.ts
+++ b/packages/backend/src/core/CustomEmojiService.ts
@@ -141,31 +141,33 @@ export class CustomEmojiService implements OnApplicationShutdown {
 	public async update(data: (
 		{ id: MiEmoji['id'], name?: string; } | { name: string; id?: MiEmoji['id'], }
 		) & {
-		originalUrl?: string;
-		publicUrl?: string;
-		fileType?: string;
-		category?: string | null;
-		aliases?: string[];
-		license?: string | null;
-		isSensitive?: boolean;
-		localOnly?: boolean;
-		roleIdsThatCanBeUsedThisEmojiAsReaction?: MiRole['id'][];
-	}, moderator?: MiUser): Promise<
+			originalUrl?: string;
+			publicUrl?: string;
+			fileType?: string;
+			category?: string | null;
+			aliases?: string[];
+			license?: string | null;
+			isSensitive?: boolean;
+			localOnly?: boolean;
+			roleIdsThatCanBeUsedThisEmojiAsReaction?: MiRole['id'][];
+		}, moderator?: MiUser): Promise<
 		null
 		| 'NO_SUCH_EMOJI'
 		| 'SAME_NAME_EMOJI_EXISTS'
-	> {
+		> {
 		const emoji = data.id
 			? await this.getEmojiById(data.id)
-			: await this.getEmojiByName(data.name!);
+			: data.name ? await this.getEmojiByName(data.name) : null;
 		if (emoji === null) return 'NO_SUCH_EMOJI';
 		const id = emoji.id;
 
 		// IDと絵文字名が両方指定されている場合は絵文字名の変更を行うため重複チェックが必要
 		const doNameUpdate = data.id && data.name && (data.name !== emoji.name);
 		if (doNameUpdate) {
-			const isDuplicate = await this.checkDuplicate(data.name!);
-			if (isDuplicate) return 'SAME_NAME_EMOJI_EXISTS';
+			if (data.name) {
+				const isDuplicate = await this.checkDuplicate(data.name);
+				if (isDuplicate) return 'SAME_NAME_EMOJI_EXISTS';
+			}
 		}
 
 		await this.emojisRepository.update(emoji.id, {