Skip to content

Commit

Permalink
Apply bad word filter also to account and display names
Browse files Browse the repository at this point in the history
  • Loading branch information
defnull committed Feb 10, 2024
1 parent aaa4f8d commit 52c588e
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion src/sources.ts
Original file line number Diff line number Diff line change
Expand Up @@ -94,8 +94,8 @@ export async function fetchPosts(cfg: Config): Promise<Post[]> {
for (const task of tasks) {
try {
(await task())
.filter(status => filterStatus(cfg, status))
.map(status => fixLocalAcct(domain, status))
.filter(status => filterStatus(cfg, status))
.map(status => statusToWallPost(cfg, status))
.forEach(addOrRepacePost)
} catch (err) {
Expand Down Expand Up @@ -200,6 +200,8 @@ const filterStatus = (cfg: Config, status: MastodonStatus) => {
if (cfg.badWords.length) {
const pattern = new RegExp(`\\b(${cfg.badWords.map(regexEscape).join("|")})\\b`, 'i');
if (status.tags?.find((tag: any) => cfg.badWords.includes(tag.name))
|| status.account.display_name.match(pattern)
|| status.account.acct.match(pattern)
|| status.content.match(pattern)
|| status.spoiler_text?.match(pattern)
|| status.media_attachments?.find(media => media.description?.match(pattern)))
Expand Down

0 comments on commit 52c588e

Please sign in to comment.