this repo has no description
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

quick automod rule to flag interactions with frequently-harassed accounts (#653)

authored by

bnewbold and committed by
GitHub
12fba48b aa88fecc

+64
+1
automod/rules/all.go
··· 24 24 YoungAccountDistinctMentionsRule, 25 25 MisleadingLinkUnicodeReversalPostRule, 26 26 SimpleBotPostRule, 27 + HarassmentTargetInteractionPostRule, 27 28 }, 28 29 ProfileRules: []automod.ProfileRuleFunc{ 29 30 GtubeProfileRule,
+3
automod/rules/example_sets.json
··· 9 9 "worst-words": [ 10 10 "veryhardar" 11 11 ], 12 + "harassment-target-dids": [ 13 + "did:web:harassed.example.com" 14 + ], 12 15 "promo-domain": [ 13 16 "buy-crypto.example.com" 14 17 ]
+60
automod/rules/harassment.go
··· 1 + package rules 2 + 3 + import ( 4 + "fmt" 5 + "time" 6 + 7 + appbsky "github.com/bluesky-social/indigo/api/bsky" 8 + "github.com/bluesky-social/indigo/atproto/syntax" 9 + "github.com/bluesky-social/indigo/automod" 10 + ) 11 + 12 + var _ automod.PostRuleFunc = HarassmentTargetInteractionPostRule 13 + 14 + // looks for new accounts, which interact with frequently-harassed accounts, and report them for review 15 + func HarassmentTargetInteractionPostRule(c *automod.RecordContext, post *appbsky.FeedPost) error { 16 + if c.Account.Private == nil || c.Account.Identity == nil { 17 + return nil 18 + } 19 + // TODO: helper for account age; and use public info for this (not private) 20 + age := time.Since(c.Account.Private.IndexedAt) 21 + if age > 7*24*time.Hour { 22 + return nil 23 + } 24 + 25 + var interactionDIDs []string 26 + facets, err := ExtractFacets(post) 27 + if err != nil { 28 + return err 29 + } 30 + for _, pf := range facets { 31 + if pf.DID != nil { 32 + interactionDIDs = append(interactionDIDs, *pf.DID) 33 + } 34 + } 35 + if post.Reply != nil && !IsSelfThread(c, post) { 36 + parentURI, err := syntax.ParseATURI(post.Reply.Parent.Uri) 37 + if err != nil { 38 + return err 39 + } 40 + interactionDIDs = append(interactionDIDs, parentURI.Authority().String()) 41 + } 42 + // TODO: quote-posts; any other interactions? 43 + if len(interactionDIDs) == 0 { 44 + return nil 45 + } 46 + 47 + interactionDIDs = dedupeStrings(interactionDIDs) 48 + for _, did := range interactionDIDs { 49 + if did == c.Account.Identity.DID.String() { 50 + continue 51 + } 52 + if c.InSet("harassment-target-dids", did) { 53 + //c.AddRecordFlag("interaction-harassed-target") 54 + c.ReportAccount(automod.ReportReasonOther, fmt.Sprintf("possible harassment of known target account: %s", did)) 55 + c.Notify("slack") 56 + return nil 57 + } 58 + } 59 + return nil 60 + }