From 52c588e834b150f7c1e96408ea75afd16ef7ce0c Mon Sep 17 00:00:00 2001 From: Marcel Hellkamp Date: Sat, 10 Feb 2024 14:02:59 +0100 Subject: [PATCH] Apply bad word filter also to account and display names --- src/sources.ts | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/sources.ts b/src/sources.ts index f0a764c..868ca61 100644 --- a/src/sources.ts +++ b/src/sources.ts @@ -94,8 +94,8 @@ export async function fetchPosts(cfg: Config): Promise { 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) { @@ -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)))