this repo has no description
0
fork

Configure Feed

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

commit-as-data helper (for JSON export)

+18
+18
atproto/repo/commit.go
··· 5 5 "fmt" 6 6 7 7 "github.com/bluesky-social/indigo/atproto/crypto" 8 + "github.com/bluesky-social/indigo/atproto/data" 8 9 "github.com/bluesky-social/indigo/atproto/syntax" 9 10 10 11 "github.com/ipfs/go-cid" ··· 37 38 return fmt.Errorf("invalid commit data: %w", err) 38 39 } 39 40 return nil 41 + } 42 + 43 + // returns a representation of the commit object as atproto data (eg, for JSON serialization) 44 + func (c *Commit) AsData() map[string]any { 45 + d := map[string]any{ 46 + "did": c.DID, 47 + "version": c.Version, 48 + "prev": (*data.CIDLink)(c.Prev), 49 + "data": data.CIDLink(c.Data), 50 + } 51 + if c.Sig != nil { 52 + d["sig"] = data.Bytes(c.Sig) 53 + } 54 + if c.Rev != "" { 55 + d["rev"] = c.Rev 56 + } 57 + return d 40 58 } 41 59 42 60 // Encodes the commit object as DAG-CBOR, without the signature field. Used for signing or validating signatures.