feat(blocklist): add url-domain host patterns (#3164)

This commit is contained in:
Hampus authored and GitHub committed 2026-10-03 14:46:08 +02:00
1 parent e9167d96ec
commit 7eebfca20b
28 files changed
+1074 -134

No files matched your search

@@ -5,7 +5,6 @@ import {Logger} from '@app/api/Logger';
import {fileShaCache} from '@app/api/middleware/FileShaCache';
import {phraseBlocklistCache} from '@app/api/middleware/PhraseBlocklistCache';
import {urlBlocklistCache} from '@app/api/middleware/UrlBlocklistCache';
import {extractUrlCandidates} from '@app/api/utils/UrlNormalizer';
import {ContentBlockedError} from '@fluxer/errors/src/domains/content/ContentBlockedError';
export interface ModerationContext {
@@ -40,16 +39,12 @@ class ContentModerationService {
);
throw new ContentBlockedError();
}
const urls = extractUrlCandidates(text);
if (urls.length === 0) return;
for (const url of urls) {
if (urlBlocklistCache.isUrlOrDomainBanned(url)) {
Logger.warn(
{surface: ctx.surface, userId: ctx.userId?.toString(), guildId: ctx.guildId?.toString()},
'content_moderation.block url match in text',
);
throw new ContentBlockedError();
}
if (urlBlocklistCache.containsBannedLink(text)) {
Logger.warn(
{surface: ctx.surface, userId: ctx.userId?.toString(), guildId: ctx.guildId?.toString()},
'content_moderation.block url match in text',
);
throw new ContentBlockedError();
}
}