mirror of
https://github.com/misskey-dev/misskey.git
synced 2026-03-21 03:30:42 +00:00
fix(backend): ワードミュートの文字数計算を修正
This commit is contained in:
@@ -20,6 +20,7 @@
|
||||
- Enhance: `clips/my-favorites` APIがページネーションに対応しました
|
||||
- Enhance: メモリ使用量を削減しました
|
||||
- Enhance: 依存関係の更新
|
||||
- Fix: ワードミュートの文字数計算を修正
|
||||
- Fix: チャンネルのリアルタイム更新時に、ロックダウン設定にて非ログイン時にノートを表示しない設定にしている場合でもノートが表示されてしまう問題を修正
|
||||
- Fix: DeepL APIのAPIキー指定方式変更に対応
|
||||
(Cherry-picked from https://github.com/MisskeyIO/misskey/pull/1096)
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user