Filter bad words also in spoiler text and media descriptions

This commit is contained in:
Marcel Hellkamp 2023-07-28 19:43:33 +02:00
parent 9f8057e4d5
commit c6abbcd342
2 changed files with 9 additions and 7 deletions

View File

@ -186,9 +186,10 @@ const filterStatus = (cfg: Config, status: MastodonStatus) => {
if (cfg.hideBots && status.account?.bot) return false;
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)))
return false;
if (status.content.match(pattern))
if (status.tags?.find((tag: any) => cfg.badWords.includes(tag.name))
|| status.content.match(pattern)
|| status.spoiler_text?.match(pattern)
|| status.media_attachments?.find(media => media.description?.match(pattern)))
return false;
}

View File

@ -68,6 +68,7 @@ export type MastodonStatus = {
media_attachments: Array<MastodonMediaAttachment>;
reblog?: MastodonStatus | null;
sensitive: boolean;
spoiler_text?: string | null;
tags: Array<MastodonTag>;
uri: string;
url?: string | null;