package models import ( "bytes" "log/slog" "time" appbsky "github.com/bluesky-social/indigo/api/bsky" "github.com/bluesky-social/indigo/atproto/syntax" ) type GraphStarterpack struct { ID string `gorm:"primaryKey"` // TODO: DescriptionFacets CreatedAt string Description *string Feeds []GraphStarterpack_Feed List string Name string AutoCreatedAt time.Time `gorm:"autoCreateTime"` AutoUpdatedAt time.Time `gorm:"autoUpdateTime"` } type GraphStarterpack_Feed struct { GraphStarterpackID string Uri string } func NewGraphStarterpack(uri syntax.ATURI, rec []byte) *GraphStarterpack { var out appbsky.GraphStarterpack if err := out.UnmarshalCBOR(bytes.NewReader(rec)); err != nil { slog.Error("could not unmarshal graph starterpack CBOR", "err", err) return nil } pack := GraphStarterpack{ ID: string(uri), CreatedAt: out.CreatedAt, Description: out.Description, List: out.List, Name: out.Name, } if out.Feeds != nil { for _, feed := range out.Feeds { pack.Feeds = append(pack.Feeds, GraphStarterpack_Feed{ GraphStarterpackID: pack.ID, Uri: feed.Uri, }) } } return &pack }