Something went wrong. Try again.
An ATProto Powered Reputation Network
Something went wrong. Try again.
1.3 kB · 41 lines
Go
at master
123456789101112131415161718192021222324252627282930313233343536373839404142package microcosm
import ( "context" "errors" "github.com/bluesky-social/indigo/atproto/syntax" "provenance/internal/atproto" "provenance/internal/domain")
func (c *Client) decodeList(ctx context.Context, e event) (domain.Change, error) { commit := e.Commit change := domain.Change{Kind: domain.RecordChange, DID: e.DID, TimeUS: e.TimeUS, Source: commit.Collection, RecordKey: commit.RecordKey} if _, err := syntax.ParseRecordKey(commit.RecordKey); err != nil { change.Kind = domain.IdentityChange return change, nil } if commit.Operation == Delete { return change, nil } if commit.Operation != Create && commit.Operation != Update { return domain.Change{}, errors.New("unsupported list operation") } var record atproto.ListRecord if !commit.hasRecord() { if commit.CID == "" { return domain.Change{}, errors.New("list event lacks its record and CID") } if err := c.rawRecord(ctx, e.DID, commit.Collection, commit.RecordKey, commit.CID, &record); err != nil { return domain.Change{}, err } } else if err := commit.readRecord(&record); err != nil { return change, nil } r, err := atproto.DecodeList(record, e.DID, commit.Collection, commit.RecordKey) if err != nil { return change, nil } change.ListRecord = &r return change, nil}