1
0
mirror of https://github.com/misskey-dev/misskey.git synced 2026-05-01 23:15:47 +02:00

fix(backend): ワードミュートの文字数計算を修正

This commit is contained in:
syuilo
2025-11-26 09:55:02 +09:00
parent cdf059cc11
commit 2ad393ea45
2 changed files with 15 additions and 2 deletions

View File

@@ -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);
}