fork of indigo with slightly nicer lexgen
0
fork

Configure Feed

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

at main 55 lines 1.6 kB view raw
1package visual 2 3import ( 4 "strings" 5 "time" 6 7 "github.com/bluesky-social/indigo/automod" 8 "github.com/bluesky-social/indigo/automod/helpers" 9 lexutil "github.com/bluesky-social/indigo/lex/util" 10) 11 12func (hal *HiveAIClient) HiveLabelBlobRule(c *automod.RecordContext, blob lexutil.LexBlob, data []byte) error { 13 14 if !strings.HasPrefix(blob.MimeType, "image/") { 15 return nil 16 } 17 18 var prescreenResult string 19 if hal.PreScreenClient != nil { 20 val, err := hal.PreScreenClient.PreScreenImage(c.Ctx, data) 21 if err != nil { 22 c.Logger.Info("prescreen-request-error", "err", err) 23 } else { 24 prescreenResult = val 25 c.Logger.Info("prescreen-request", "uri", c.RecordOp.ATURI(), "result", prescreenResult) 26 } 27 } 28 29 labels, err := hal.LabelBlob(c.Ctx, blob, data) 30 if err != nil { 31 return err 32 } 33 34 if hal.PreScreenClient != nil { 35 if prescreenResult == "sfw" { 36 if len(labels) > 0 { 37 c.Logger.Info("prescreen-safe-failure", "uri", c.RecordOp.ATURI(), "labels", labels, "result", prescreenResult) 38 } else { 39 c.Logger.Info("prescreen-safe-success", "uri", c.RecordOp.ATURI()) 40 } 41 } 42 } 43 44 for _, l := range labels { 45 // NOTE: experimenting with profile reporting for new accounts 46 if l == "sexual" && c.RecordOp.Collection.String() == "app.bsky.actor.profile" && helpers.AccountIsYoungerThan(&c.AccountContext, 2*24*time.Hour) { 47 c.ReportRecord(automod.ReportReasonSexual, "possible sexual profile (not labeled yet)") 48 c.Logger.Info("skipping record label", "label", l, "reason", "sexual-profile-experiment") 49 } else { 50 c.AddRecordLabel(l) 51 } 52 } 53 54 return nil 55}