summaryrefslogtreecommitdiff
path: root/packages/backend/src/server/api/endpoints
diff options
context:
space:
mode:
Diffstat (limited to 'packages/backend/src/server/api/endpoints')
-rw-r--r--packages/backend/src/server/api/endpoints/i/update.ts9
1 files changed, 7 insertions, 2 deletions
diff --git a/packages/backend/src/server/api/endpoints/i/update.ts b/packages/backend/src/server/api/endpoints/i/update.ts
index ad8f38703b..f35e395841 100644
--- a/packages/backend/src/server/api/endpoints/i/update.ts
+++ b/packages/backend/src/server/api/endpoints/i/update.ts
@@ -330,8 +330,13 @@ export default class extends Endpoint<typeof meta, typeof paramDef> { // eslint-
if (ps.chatScope !== undefined) updates.chatScope = ps.chatScope;
function checkMuteWordCount(mutedWords: (string[] | string)[], limit: number) {
- // TODO: ちゃんと数える
- const length = JSON.stringify(mutedWords).length;
+ const length = mutedWords.reduce((sum, word) => {
+ const wordLength = Array.isArray(word)
+ ? word.reduce((l, w) => l + w.length, 0)
+ : word.length;
+ return sum + wordLength;
+ }, 0);
+
if (length > limit) {
throw new ApiError(meta.errors.tooManyMutedWords);
}