mirror of
https://akkoma.dev/AkkomaGang/akkoma-fe
synced 2025-05-10 14:39:14 +08:00
Apply wordfilters to attachment alt-texts
EDITED to apply review suggestions: - short circuit search and immediately return once match found - Array.some() instead of for loop
This commit is contained in:
parent
851dd263c0
commit
94c5998593
1 changed files with 8 additions and 1 deletions
|
@ -3,8 +3,15 @@ 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()
|
||||
|
||||
return (
|
||||
statusText.includes(muteWord) ||
|
||||
statusSummary.includes(muteWord) ||
|
||||
status.attachments.some((a) => a.description?.toLowerCase().includes(muteWord))
|
||||
)
|
||||
})
|
||||
|
||||
return hits
|
||||
|
|
Loading…
Reference in a new issue