diff --git a/automod/capture/fetch.go b/automod/capture/fetch.go index 17fff408..9fef6046 100644 --- a/automod/capture/fetch.go +++ b/automod/capture/fetch.go @@ -47,7 +47,7 @@ func FetchAndProcessRecord(ctx context.Context, eng *automod.Engine, aturi synta Collection: aturi.Collection(), RecordKey: aturi.RecordKey(), CID: &recCID, - RecordCBOR: &recBytes, + RecordCBOR: recBytes, } return eng.ProcessRecordOp(ctx, op) } @@ -96,7 +96,7 @@ func FetchAndProcessRecent(ctx context.Context, eng *automod.Engine, atid syntax Collection: aturi.Collection(), RecordKey: aturi.RecordKey(), CID: &recCID, - RecordCBOR: &recBytes, + RecordCBOR: recBytes, } err = eng.ProcessRecordOp(ctx, op) if err != nil { diff --git a/automod/capture/testing.go b/automod/capture/testing.go index b8a4e32c..998aaef4 100644 --- a/automod/capture/testing.go +++ b/automod/capture/testing.go @@ -68,7 +68,7 @@ func ProcessCaptureRules(eng *automod.Engine, capture AccountCapture) error { Collection: aturi.Collection(), RecordKey: aturi.RecordKey(), CID: &recCID, - RecordCBOR: &recBytes, + RecordCBOR: recBytes, } eng.ProcessRecordOp(ctx, op) } diff --git a/automod/engine/action_dedupe_test.go b/automod/engine/action_dedupe_test.go index 313f0fe0..b07a2a43 100644 --- a/automod/engine/action_dedupe_test.go +++ b/automod/engine/action_dedupe_test.go @@ -46,7 +46,7 @@ func TestAccountReportDedupe(t *testing.T) { Collection: "app.bsky.feed.post", RecordKey: "abc123", CID: &cid1, - RecordCBOR: &p1cbor, + RecordCBOR: p1cbor, } for i := 0; i < 5; i++ { assert.NoError(eng.ProcessRecordOp(ctx, op)) diff --git a/automod/engine/blobs.go b/automod/engine/blobs.go index 7b5ae797..fe6f4940 100644 --- a/automod/engine/blobs.go +++ b/automod/engine/blobs.go @@ -22,7 +22,7 @@ func (c *RecordContext) Blobs() ([]lexutil.LexBlob, error) { return []lexutil.LexBlob{}, nil } - rec, err := data.UnmarshalCBOR(*c.RecordOp.RecordCBOR) + rec, err := data.UnmarshalCBOR(c.RecordOp.RecordCBOR) if err != nil { return nil, fmt.Errorf("parsing generic record CBOR: %v", err) } diff --git a/automod/engine/circuit_breaker_test.go b/automod/engine/circuit_breaker_test.go index 77ab488d..43c38393 100644 --- a/automod/engine/circuit_breaker_test.go +++ b/automod/engine/circuit_breaker_test.go @@ -56,7 +56,7 @@ func TestTakedownCircuitBreaker(t *testing.T) { Collection: syntax.NSID("app.bsky.feed.post"), RecordKey: syntax.RecordKey("abc123"), CID: &cid1, - RecordCBOR: &p1cbor, + RecordCBOR: p1cbor, } assert.NoError(eng.ProcessRecordOp(ctx, op)) } @@ -101,7 +101,7 @@ func TestReportCircuitBreaker(t *testing.T) { Collection: syntax.NSID("app.bsky.feed.post"), RecordKey: syntax.RecordKey("abc123"), CID: &cid1, - RecordCBOR: &p1cbor, + RecordCBOR: p1cbor, } assert.NoError(eng.ProcessRecordOp(ctx, op)) } diff --git a/automod/engine/context.go b/automod/engine/context.go index 8f9f1dea..56b5586a 100644 --- a/automod/engine/context.go +++ b/automod/engine/context.go @@ -52,7 +52,7 @@ type RecordOp struct { Collection syntax.NSID RecordKey syntax.RecordKey CID *syntax.CID - RecordCBOR *[]byte + RecordCBOR []byte } // Originally intended for push notifications, but can also work for any inter-account notification. diff --git a/automod/engine/engine_test.go b/automod/engine/engine_test.go index fc792812..0cbf3035 100644 --- a/automod/engine/engine_test.go +++ b/automod/engine/engine_test.go @@ -35,7 +35,7 @@ func TestEngineBasics(t *testing.T) { Collection: syntax.NSID("app.bsky.feed.post"), RecordKey: syntax.RecordKey("abc123"), CID: &cid1, - RecordCBOR: &p1cbor, + RecordCBOR: p1cbor, } assert.NoError(eng.ProcessRecordOp(ctx, op)) @@ -46,6 +46,6 @@ func TestEngineBasics(t *testing.T) { p2buf := new(bytes.Buffer) assert.NoError(p2.MarshalCBOR(p2buf)) p2cbor := p2buf.Bytes() - op.RecordCBOR = &p2cbor + op.RecordCBOR = p2cbor assert.NoError(eng.ProcessRecordOp(ctx, op)) } diff --git a/automod/engine/ruleset.go b/automod/engine/ruleset.go index c49014e5..0c691f4c 100644 --- a/automod/engine/ruleset.go +++ b/automod/engine/ruleset.go @@ -33,7 +33,7 @@ func (r *RuleSet) CallRecordRules(c *RecordContext) error { switch c.RecordOp.Collection.String() { case "app.bsky.feed.post": var post appbsky.FeedPost - if err := post.UnmarshalCBOR(bytes.NewReader(*c.RecordOp.RecordCBOR)); err != nil { + if err := post.UnmarshalCBOR(bytes.NewReader(c.RecordOp.RecordCBOR)); err != nil { return fmt.Errorf("failed to parse app.bsky.feed.post record: %v", err) } for _, f := range r.PostRules { @@ -44,7 +44,7 @@ func (r *RuleSet) CallRecordRules(c *RecordContext) error { } case "app.bsky.actor.profile": var profile appbsky.ActorProfile - if err := profile.UnmarshalCBOR(bytes.NewReader(*c.RecordOp.RecordCBOR)); err != nil { + if err := profile.UnmarshalCBOR(bytes.NewReader(c.RecordOp.RecordCBOR)); err != nil { return fmt.Errorf("failed to parse app.bsky.actor.profile record: %v", err) } for _, f := range r.ProfileRules { diff --git a/automod/rules/hashtags_test.go b/automod/rules/hashtags_test.go index 92c9bcd8..e7c261d4 100644 --- a/automod/rules/hashtags_test.go +++ b/automod/rules/hashtags_test.go @@ -38,7 +38,7 @@ func TestBadHashtagPostRule(t *testing.T) { Collection: syntax.NSID("app.bsky.feed.post"), RecordKey: syntax.RecordKey("abc123"), CID: &cid1, - RecordCBOR: &p1cbor, + RecordCBOR: p1cbor, } c1 := engine.NewRecordContext(ctx, &eng, am1, op) assert.NoError(BadHashtagsPostRule(&c1, &p1)) @@ -52,7 +52,7 @@ func TestBadHashtagPostRule(t *testing.T) { p2buf := new(bytes.Buffer) assert.NoError(p2.MarshalCBOR(p2buf)) p2cbor := p2buf.Bytes() - op.RecordCBOR = &p2cbor + op.RecordCBOR = p2cbor c2 := engine.NewRecordContext(ctx, &eng, am1, op) assert.NoError(BadHashtagsPostRule(&c2, &p2)) eff2 := engine.ExtractEffects(&c2.BaseContext) diff --git a/automod/rules/keyword.go b/automod/rules/keyword.go index c013a1af..b604e42b 100644 --- a/automod/rules/keyword.go +++ b/automod/rules/keyword.go @@ -84,7 +84,7 @@ func BadWordOtherRecordRule(c *automod.RecordContext) error { switch c.RecordOp.Collection.String() { case "app.bsky.graph.list": var list appbsky.GraphList - if err := list.UnmarshalCBOR(bytes.NewReader(*c.RecordOp.RecordCBOR)); err != nil { + if err := list.UnmarshalCBOR(bytes.NewReader(c.RecordOp.RecordCBOR)); err != nil { return fmt.Errorf("failed to parse app.bsky.graph.list record: %v", err) } name += " " + list.Name @@ -96,7 +96,7 @@ func BadWordOtherRecordRule(c *automod.RecordContext) error { } case "app.bsky.feed.generator": var generator appbsky.FeedGenerator - if err := generator.UnmarshalCBOR(bytes.NewReader(*c.RecordOp.RecordCBOR)); err != nil { + if err := generator.UnmarshalCBOR(bytes.NewReader(c.RecordOp.RecordCBOR)); err != nil { return fmt.Errorf("failed to parse app.bsky.feed.generator record: %v", err) } name += " " + generator.DisplayName diff --git a/automod/rules/keyword_test.go b/automod/rules/keyword_test.go index 6daf26a2..465bdbb4 100644 --- a/automod/rules/keyword_test.go +++ b/automod/rules/keyword_test.go @@ -80,7 +80,7 @@ func TestBadWordPostRule(t *testing.T) { Collection: syntax.NSID("app.bsky.feed.post"), RecordKey: syntax.RecordKey("fagg0t"), CID: &cid1, - RecordCBOR: &p1cbor, + RecordCBOR: p1cbor, } c1 := engine.NewRecordContext(ctx, &eng, am1, op) assert.NoError(BadWordRecordKeyRule(&c1)) @@ -100,7 +100,7 @@ func TestBadWordPostRule(t *testing.T) { Collection: syntax.NSID("app.bsky.feed.post"), RecordKey: syntax.RecordKey("abc123"), CID: &cid1, - RecordCBOR: &p2cbor, + RecordCBOR: p2cbor, } c2 := engine.NewRecordContext(ctx, &eng, am1, op2) assert.NoError(BadWordPostRule(&c2, &p2)) diff --git a/automod/rules/misleading_test.go b/automod/rules/misleading_test.go index 174abb8d..cf8e814a 100644 --- a/automod/rules/misleading_test.go +++ b/automod/rules/misleading_test.go @@ -54,7 +54,7 @@ func TestMisleadingURLPostRule(t *testing.T) { Collection: syntax.NSID("app.bsky.feed.post"), RecordKey: syntax.RecordKey("abc123"), CID: &cid1, - RecordCBOR: &p1cbor, + RecordCBOR: p1cbor, } c1 := engine.NewRecordContext(ctx, &eng, am1, op) assert.NoError(MisleadingURLPostRule(&c1, &p1)) @@ -101,7 +101,7 @@ func TestMisleadingMentionPostRule(t *testing.T) { Collection: syntax.NSID("app.bsky.feed.post"), RecordKey: syntax.RecordKey("abc123"), CID: &cid1, - RecordCBOR: &p1cbor, + RecordCBOR: p1cbor, } c1 := engine.NewRecordContext(ctx, &eng, am1, op) assert.NoError(MisleadingMentionPostRule(&c1, &p1)) diff --git a/cmd/hepa/consumer.go b/cmd/hepa/consumer.go index c786becb..0fc1c951 100644 --- a/cmd/hepa/consumer.go +++ b/cmd/hepa/consumer.go @@ -188,7 +188,7 @@ func (s *Server) HandleRepoCommit(ctx context.Context, evt *comatproto.SyncSubsc Collection: collection, RecordKey: rkey, CID: &recCID, - RecordCBOR: recCBOR, + RecordCBOR: *recCBOR, }) if err != nil { logger.Error("engine failed to process record", "err", err)