fork of indigo with slightly nicer lexgen
at main 1.4 kB view raw
1package visual 2 3import ( 4 "strings" 5 6 "github.com/bluesky-social/indigo/automod" 7 lexutil "github.com/bluesky-social/indigo/lex/util" 8) 9 10func (ac *AbyssClient) AbyssScanBlobRule(c *automod.RecordContext, blob lexutil.LexBlob, data []byte) error { 11 12 if !strings.HasPrefix(blob.MimeType, "image/") { 13 return nil 14 } 15 16 params := make(map[string]string) 17 params["did"] = c.Account.Identity.DID.String() 18 if !c.Account.Identity.Handle.IsInvalidHandle() { 19 params["handle"] = c.Account.Identity.Handle.String() 20 } 21 if c.Account.Private != nil && c.Account.Private.Email != "" { 22 params["accountEmail"] = c.Account.Private.Email 23 } 24 params["uri"] = c.RecordOp.ATURI().String() 25 26 resp, err := ac.ScanBlob(c.Ctx, blob, data, params) 27 if err != nil { 28 return err 29 } 30 31 if resp.Match == nil || resp.Match.Status != "success" { 32 // TODO: should this return an error, or just log? 33 c.Logger.Error("abyss blob scan failed", "cid", blob.Ref.String()) 34 return nil 35 } 36 37 if resp.Match.IsAbuseMatch() { 38 c.Logger.Warn("abyss blob match", "cid", blob.Ref.String()) 39 c.AddRecordFlag("abyss-match") 40 c.TakedownRecord() 41 // purge blob as part of record takedown 42 c.TakedownBlob(blob.Ref.String()) 43 c.ReportRecord(automod.ReportReasonViolation, "possible CSAM image match; post has been takendown while verifying.\nAccount should be reviewed for any other content") 44 } 45 46 return nil 47}