···55 "fmt"
66 "log/slog"
77 "strings"
88- "sync"
98109 appbsky "github.com/bluesky-social/indigo/api/bsky"
1110 "github.com/bluesky-social/indigo/atproto/identity"
1211 "github.com/bluesky-social/indigo/atproto/syntax"
1313- "github.com/bluesky-social/indigo/xrpc"
1412)
15131614// runtime for executing rules, managing state, and recording moderation actions.
1715//
1816// TODO: careful when initializing: several fields should not be null or zero, even though they are pointer type.
1917type Engine struct {
2020- Logger *slog.Logger
1818+ Logger *slog.Logger
2119 Directory identity.Directory
2220 // current rule sets. will eventually be possible to swap these out at runtime
2323- RulesMap sync.Map
2121+ // TODO: RulesMap sync.Map
2422 // used to persist moderation actions in mod service (optional)
2525- AdminClient *xrpc.Client
2626- CountStore CountStore
2323+ // TODO: AdminClient *xrpc.Client
2424+ Counters CountStore
2525+ Sets SetStore
2726}
28272928func (e *Engine) ProcessIdentityEvent(ctx context.Context, t string, did syntax.DID) error {
···92919392func (e *Engine) NewPostEvent(ident *identity.Identity, path string, post *appbsky.FeedPost) PostEvent {
9493 return PostEvent{
9595- RecordEvent {
9494+ RecordEvent{
9695 Event{
9796 Engine: e,
9897 Account: AccountMeta{Identity: ident},
···119118}
120119121120func (e *Engine) GetCount(key, period string) (int, error) {
122122- return e.CountStore.GetCount(context.TODO(), key, period)
121121+ return e.Counters.GetCount(context.TODO(), key, period)
123122}
124123125125-func (e *Engine) InSet(setName, val string) (bool, error) {
126126- // XXX: implement
127127- return false, nil
124124+// checks if `val` is an element of set `name`
125125+func (e *Engine) InSet(name, val string) (bool, error) {
126126+ return e.Sets.InSet(context.TODO(), name, val)
128127}