an app.bsky.* indexer
1package models 2 3import ( 4 "bytes" 5 "log/slog" 6 "time" 7 8 appbsky "github.com/bluesky-social/indigo/api/bsky" 9 "github.com/bluesky-social/indigo/atproto/syntax" 10) 11 12type GraphStarterpack struct { 13 ID string `gorm:"primaryKey"` 14 15 // TODO: DescriptionFacets 16 17 CreatedAt string 18 Description *string 19 Feeds []GraphStarterpack_Feed 20 List string 21 Name string 22 23 AutoCreatedAt time.Time `gorm:"autoCreateTime"` 24 AutoUpdatedAt time.Time `gorm:"autoUpdateTime"` 25} 26 27type GraphStarterpack_Feed struct { 28 GraphStarterpackID string 29 Uri string 30} 31 32func NewGraphStarterpack(uri syntax.ATURI, rec []byte) *GraphStarterpack { 33 var out appbsky.GraphStarterpack 34 if err := out.UnmarshalCBOR(bytes.NewReader(rec)); err != nil { 35 slog.Error("could not unmarshal graph starterpack CBOR", "err", err) 36 return nil 37 } 38 39 pack := GraphStarterpack{ 40 ID: string(uri), 41 CreatedAt: out.CreatedAt, 42 Description: out.Description, 43 List: out.List, 44 Name: out.Name, 45 } 46 47 if out.Feeds != nil { 48 for _, feed := range out.Feeds { 49 pack.Feeds = append(pack.Feeds, GraphStarterpack_Feed{ 50 GraphStarterpackID: pack.ID, 51 Uri: feed.Uri, 52 }) 53 } 54 } 55 56 return &pack 57}