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 CreatedAt: out.CreatedAt,
41 Description: out.Description,
42 List: out.List,
43 Name: out.Name,
44 }
45
46 if out.Feeds != nil {
47 for _, feed := range out.Feeds {
48 pack.Feeds = append(pack.Feeds, GraphStarterpack_Feed{
49 Uri: feed.Uri,
50 })
51 }
52 }
53
54 return &pack
55}