Something went wrong. Try again.
An ATProto Powered Reputation Network
Something went wrong. Try again.
1.5 kB · 52 lines
Go
at master
1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253package domain
import "errors"
type SoftMode int
const ( SoftDisabled SoftMode = iota SoftParticipants SoftAllAuthors SoftParticipantLists SoftAllAuthorLists)
const ( FollowCollection = "app.bsky.graph.follow" BlockCollection = "app.bsky.graph.block" FollowScore = 0.5 SoftBlockScore = -0.5 ListBlockCollection = "app.bsky.graph.listblock" ListItemCollection = "app.bsky.graph.listitem" ListCollection = "app.bsky.graph.list" ModerationList = "app.bsky.graph.defs#modlist")
func SoftSource(source string) bool { return source == FollowCollection || source == BlockCollection || source == ListBlockCollection}
func ListSource(source string) bool { return source == ListCollection || source == ListItemCollection || source == ListBlockCollection}func SoftLists(mode SoftMode) bool { return mode == SoftParticipantLists || mode == SoftAllAuthorLists }func SoftAll(mode SoftMode) bool { return mode == SoftAllAuthors || mode == SoftAllAuthorLists }
func SourceScore(source string) float64 { if source == FollowCollection { return FollowScore } return SoftBlockScore}
// Virtual assertions have fixed weights. Explicit records retain integer-only validation.func ValidateVouch(v Vouch) error { if v.Source == "" || v.Source == Collection { return ValidateScore(v.Score) } if !SoftSource(v.Source) || v.Score != SourceScore(v.Source) || v.Tag != "" || v.Comment != "" || v.RecordKey == "" { return errors.New("invalid soft vouch") } return nil}