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

Refactor countStarterPacks rule

Allowlists are now checked via an array. Added more logging. Improved
error handling.

Refactor countStarterPacks rule

Use a whitelist for allowed DIDs and improve logging.

Skywatch dade9598 8d9e0aa7

+23 -3
+23 -3
src/rules/account/countStarterPacks.ts
··· 3 3 import { limit } from "../../limits.js"; 4 4 import { createAccountLabel } from "../../moderation.js"; 5 5 6 + const ALLOWED_DIDS = ["did:plc:gpunjjgvlyb4racypz3yfiq4"]; 7 + 6 8 export const countStarterPacks = async (did: string, time: number) => { 7 9 await isLoggedIn; 8 10 9 - if (did in ["did:plc:gpunjjgvlyb4racypz3yfiq4"]) { 11 + if (ALLOWED_DIDS.includes(did)) { 10 12 logger.debug( 11 13 { process: "COUNTSTARTERPACKS", did, time }, 12 14 "Account is whitelisted", ··· 20 22 const starterPacks = profile.data.associated?.starterPacks; 21 23 22 24 if (starterPacks && starterPacks.valueOf() > 20) { 25 + logger.info( 26 + { 27 + process: "COUNTSTARTERPACKS", 28 + did, 29 + time, 30 + starterPackCount: starterPacks.valueOf(), 31 + }, 32 + "Labeling account with excessive starter packs", 33 + ); 34 + 23 35 createAccountLabel( 24 36 did, 25 37 "follow-farming", 26 - `[COUNTSTARTERPACKS]: ${time}: Account ${did} has ${starterPacks} starter packs.`, 38 + `${time}: Account has ${starterPacks} starter packs`, 27 39 ); 28 40 } 29 41 } catch (error) { 42 + const errorInfo = 43 + error instanceof Error 44 + ? { 45 + name: error.name, 46 + message: error.message, 47 + } 48 + : { error: String(error) }; 49 + 30 50 logger.error( 31 - { process: "COUNTSTARTERPACKS", error }, 51 + { process: "COUNTSTARTERPACKS", did, time, ...errorInfo }, 32 52 "Error checking associated accounts", 33 53 ); 34 54 }