summaryrefslogtreecommitdiff
path: root/packages/backend/src
diff options
context:
space:
mode:
authorsyuilo <4439005+syuilo@users.noreply.github.com>2025-11-26 09:55:02 +0900
committersyuilo <4439005+syuilo@users.noreply.github.com>2025-11-26 09:55:02 +0900
commit2ad393ea45931a9a17207d91f17fcb48b81a0e88 (patch)
tree60397f4c5c29488ff95d4accf4120cf8b3da258e /packages/backend/src
parentchore(dev): use postgresql 18 (#16850) (diff)
downloadmisskey-2ad393ea45931a9a17207d91f17fcb48b81a0e88.tar.gz
misskey-2ad393ea45931a9a17207d91f17fcb48b81a0e88.tar.bz2
misskey-2ad393ea45931a9a17207d91f17fcb48b81a0e88.zip
fix(backend): ワードミュートの文字数計算を修正
Diffstat (limited to 'packages/backend/src')
-rw-r--r--packages/backend/src/server/api/endpoints/i/update.ts16
1 files changed, 14 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 5c7958fc1c..113a09cb14 100644
--- a/packages/backend/src/server/api/endpoints/i/update.ts
+++ b/packages/backend/src/server/api/endpoints/i/update.ts
@@ -295,8 +295,20 @@ 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 count = (arr: (string[] | string)[]) => {
+ let length = 0;
+ for (const item of arr) {
+ if (typeof item === 'string') {
+ length += item.length;
+ } else if (Array.isArray(item)) {
+ for (const subItem of item) {
+ length += subItem.length;
+ }
+ }
+ }
+ return length;
+ };
+ const length = count(mutedWords);
if (length > limit) {
throw new ApiError(meta.errors.tooManyMutedWords);
}