+7
cmd/monarch/handlers.go
+7
cmd/monarch/handlers.go
···
43
43
&models.FeedThreadgate_HiddenReply{},
44
44
45
45
&models.GraphBlock{},
46
+
&models.GraphFollow{},
46
47
&models.GraphList{},
47
48
&models.GraphListblock{},
48
49
&models.GraphListitem{},
···
126
127
block := models.NewGraphBlock(uri, *rec)
127
128
if err := hs.store.Where(models.GraphBlock{ID: string(uri)}).Assign(block).FirstOrCreate(&models.GraphBlock{}).Error; err != nil {
128
129
return fmt.Errorf("error upserting graph block: %w", err)
130
+
}
131
+
132
+
case syntax.NSID("app.bsky.graph.follow"):
133
+
follow := models.NewGraphFollow(uri, *rec)
134
+
if err := hs.store.Where(models.GraphFollow{ID: string(uri)}).Assign(follow).FirstOrCreate(&models.GraphFollow{}).Error; err != nil {
135
+
return fmt.Errorf("error upserting graph follow: %w", err)
129
136
}
130
137
131
138
case syntax.NSID("app.bsky.graph.list"):
+35
models/graph_follow.go
+35
models/graph_follow.go
···
1
+
package models
2
+
3
+
import (
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
+
12
+
type 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
+
22
+
func 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
+
follow := GraphFollow{
30
+
CreatedAt: out.CreatedAt,
31
+
Subject: out.Subject,
32
+
}
33
+
34
+
return &follow
35
+
}