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