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 GraphFollow struct { 13 ID string `gorm:"primaryKey"` 14 15 CreatedAt string 16 Subject string 17 18 AutoCreatedAt time.Time `gorm:"autoCreateTime"` 19 AutoUpdatedAt time.Time `gorm:"autoUpdateTime"` 20} 21 22func NewGraphFollow(uri syntax.ATURI, rec []byte) *GraphFollow { 23 var out appbsky.GraphFollow 24 if err := out.UnmarshalCBOR(bytes.NewReader(rec)); err != nil { 25 slog.Error("could not unmarshal graph follow CBOR", "err", err) 26 return nil 27 } 28 29 return &GraphFollow{ 30 ID: string(uri), 31 CreatedAt: out.CreatedAt, 32 Subject: out.Subject, 33 } 34}