mirror of
https://github.com/defnull/fediwall.git
synced 2024-11-28 10:33:30 +01:00
Apply bad word filter also to account and display names
This commit is contained in:
parent
aaa4f8d4ae
commit
52c588e834
@ -94,8 +94,8 @@ export async function fetchPosts(cfg: Config): Promise<Post[]> {
|
|||||||
for (const task of tasks) {
|
for (const task of tasks) {
|
||||||
try {
|
try {
|
||||||
(await task())
|
(await task())
|
||||||
.filter(status => filterStatus(cfg, status))
|
|
||||||
.map(status => fixLocalAcct(domain, status))
|
.map(status => fixLocalAcct(domain, status))
|
||||||
|
.filter(status => filterStatus(cfg, status))
|
||||||
.map(status => statusToWallPost(cfg, status))
|
.map(status => statusToWallPost(cfg, status))
|
||||||
.forEach(addOrRepacePost)
|
.forEach(addOrRepacePost)
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
@ -200,6 +200,8 @@ const filterStatus = (cfg: Config, status: MastodonStatus) => {
|
|||||||
if (cfg.badWords.length) {
|
if (cfg.badWords.length) {
|
||||||
const pattern = new RegExp(`\\b(${cfg.badWords.map(regexEscape).join("|")})\\b`, 'i');
|
const pattern = new RegExp(`\\b(${cfg.badWords.map(regexEscape).join("|")})\\b`, 'i');
|
||||||
if (status.tags?.find((tag: any) => cfg.badWords.includes(tag.name))
|
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.content.match(pattern)
|
||||||
|| status.spoiler_text?.match(pattern)
|
|| status.spoiler_text?.match(pattern)
|
||||||
|| status.media_attachments?.find(media => media.description?.match(pattern)))
|
|| status.media_attachments?.find(media => media.description?.match(pattern)))
|
||||||
|
Loading…
Reference in New Issue
Block a user