[feat] apply wordfilters to attachment alt-texts #384

Open
sn0w wants to merge 1 commit from sn0w/akkoma-fe:feature/alt-text-filters into develop
Showing only changes of commit 6f48569e59 - Show all commits

View file

@ -3,8 +3,17 @@ import { filter } from 'lodash'
export const muteWordHits = (status, muteWords) => {
const statusText = status.text.toLowerCase()
const statusSummary = status.summary.toLowerCase()
const hits = filter(muteWords, (muteWord) => {
return statusText.includes(muteWord.toLowerCase()) || statusSummary.includes(muteWord.toLowerCase())
muteWord = muteWord.toLowerCase()
let res = statusText.includes(muteWord) || statusSummary.includes(muteWord)
for (let attachment of status.attachments) {
res |= attachment.description?.toLowerCase().includes(muteWord)
}
Review

nit: this could directly return as soon as something matches the word

nit: this could directly return as soon as something matches the word
Review

it could also be rewritten as a .some call to remove the loop entirely

res |= status.attachments.some((attachment) => ...)

it could also be rewritten as a `.some` call to remove the loop entirely res |= status.attachments.some((attachment) => ...)
return res
})
return hits