make mutes case insensitive
Some checks failed
ci/woodpecker/push/lint-client Pipeline failed
ci/woodpecker/push/lint-backend Pipeline failed
ci/woodpecker/push/build Pipeline was successful
ci/woodpecker/push/lint-foundkey-js Pipeline was successful
ci/woodpecker/push/lint-sw Pipeline failed
ci/woodpecker/push/test Pipeline failed

closes #392

Changelog: Changed
This commit is contained in:
Johann150 2023-05-31 12:58:50 +02:00
parent af003fc0fe
commit a0f0bac1ca
Signed by: Johann150
GPG key ID: 9EE6577A2A06F8F1
2 changed files with 4 additions and 2 deletions

View file

@ -20,10 +20,11 @@ export async function checkWordMute(note: NoteLike, me: UserLike | null | undefi
const text = ((note.cw ?? '') + '\n' + (note.text ?? '')).trim(); const text = ((note.cw ?? '') + '\n' + (note.text ?? '')).trim();
if (text === '') return false; if (text === '') return false;
const textLower = text.toLowerCase();
const matched = mutedWords.some(filter => { const matched = mutedWords.some(filter => {
if (Array.isArray(filter)) { if (Array.isArray(filter)) {
return filter.every(keyword => text.includes(keyword)); return filter.every(keyword => textLower.includes(keyword.toLowerCase()));
} else { } else {
// represents RegExp // represents RegExp
const regexp = filter.match(/^\/(.+)\/(.*)$/); const regexp = filter.match(/^\/(.+)\/(.*)$/);

View file

@ -6,6 +6,7 @@ export function checkWordMute(note: Record<string, any>, me: Record<string, any>
const text = ((note.cw ?? '') + '\n' + (note.text ?? '')).trim(); const text = ((note.cw ?? '') + '\n' + (note.text ?? '')).trim();
if (text === '') return false; if (text === '') return false;
const textLower = text.toLowerCase();
const matched = mutedWords.some(filter => { const matched = mutedWords.some(filter => {
if (Array.isArray(filter)) { if (Array.isArray(filter)) {
@ -13,7 +14,7 @@ export function checkWordMute(note: Record<string, any>, me: Record<string, any>
const filteredFilter = filter.filter(keyword => keyword !== ''); const filteredFilter = filter.filter(keyword => keyword !== '');
if (filteredFilter.length === 0) return false; if (filteredFilter.length === 0) return false;
return filteredFilter.every(keyword => text.includes(keyword)); return filteredFilter.every(keyword => textLower.includes(keyword.toLowerCase()));
} else { } else {
// represents RegExp // represents RegExp
const regexp = filter.match(/^\/(.+)\/(.*)$/); const regexp = filter.match(/^\/(.+)\/(.*)$/);