A tool for parsing traffic on the jetstream and applying a moderation workstream based on regexp based rules

Add facet spam allowlist (to allow for test scenarios)

+15 -1
+14
src/rules/facets/facets.ts
··· 10 10 export const FACET_SPAM_COMMENT = 11 11 "Abusive facet usage detected (hidden mentions)"; 12 12 13 + // Allowlist for DIDs with legitimate duplicate facet use cases 14 + export const FACET_SPAM_ALLOWLIST: string[] = [ 15 + // Add DIDs here that should be exempt from facet spam detection 16 + ]; 17 + 13 18 /** 14 19 * Checks if a post contains facet spam by detecting multiple facets 15 20 * with identical byte positions (indicating hidden/abusive mentions) ··· 20 25 atURI: string, 21 26 facets: Facet[], 22 27 ): Promise<void> => { 28 + // Check allowlist 29 + if (FACET_SPAM_ALLOWLIST.includes(did)) { 30 + logger.debug( 31 + { process: "FACET_SPAM", did, atURI }, 32 + "Allowlisted DID", 33 + ); 34 + return; 35 + } 36 + 23 37 if (!facets || facets.length === 0) { 24 38 return; 25 39 }
+1 -1
src/rules/facets/tests/facets.test.ts
··· 1 1 import { describe, it, expect, vi, beforeEach } from "vitest"; 2 - import { checkFacetSpam, FACET_SPAM_THRESHOLD, FACET_SPAM_LABEL, FACET_SPAM_COMMENT } from "../facets.js"; 2 + import { checkFacetSpam, FACET_SPAM_THRESHOLD, FACET_SPAM_LABEL, FACET_SPAM_COMMENT, FACET_SPAM_ALLOWLIST } from "../facets.js"; 3 3 import { Facet } from "../../../types.js"; 4 4 5 5 // Mock dependencies