an app.bsky.* indexer

add GraphListblock

Changed files
+41 -5
cmd
monarch
models
+7 -4
cmd/monarch/handlers.go
···
&models.ActorProfile_Label{},
&models.ActorProfile_JoinedViaStarterPack{},
&models.ActorProfile_PinnedPost{},
-
&models.ActorStatus{},
&models.ActorStatus_Embed{},
-
&models.FeedGenerator{},
&models.FeedGenerator_Label{},
-
&models.GraphBlock{},
-
&models.GraphList{},
+
&models.GraphListblock{},
}
for _, migration := range migrations {
store.AutoMigrate(migration)
···
list := models.NewGraphList(uri, *rec)
if err := hs.store.Where(models.GraphList{ID: string(uri)}).Assign(list).FirstOrCreate(&models.GraphList{}).Error; err != nil {
return fmt.Errorf("error upserting graph list: %w", err)
+
}
+
+
case syntax.NSID("app.bsky.graph.listblock"):
+
listblock := models.NewGraphListblock(uri, *rec)
+
if err := hs.store.Where(models.GraphListblock{ID: string(uri)}).Assign(listblock).FirstOrCreate(&models.GraphListblock{}).Error; err != nil {
+
return fmt.Errorf("error upserting graph listblock: %w", err)
}
}
+33
models/graph_listblock.go
···
+
package models
+
+
import (
+
"bytes"
+
"log/slog"
+
"time"
+
+
appbsky "github.com/bluesky-social/indigo/api/bsky"
+
"github.com/bluesky-social/indigo/atproto/syntax"
+
)
+
+
type GraphListblock struct {
+
ID string `gorm:"primaryKey"`
+
+
CreatedAt string
+
Subject string
+
+
AutoCreatedAt time.Time `gorm:"autoCreateTime"`
+
AutoUpdatedAt time.Time `gorm:"autoUpdateTime"`
+
}
+
+
func NewGraphListblock(uri syntax.ATURI, rec []byte) *GraphListblock {
+
var out appbsky.GraphListblock
+
if err := out.UnmarshalCBOR(bytes.NewReader(rec)); err != nil {
+
slog.Error("could not unmarshal graph listblock CBOR", "err", err)
+
return nil
+
}
+
+
return &GraphListblock{
+
CreatedAt: out.CreatedAt,
+
Subject: out.Subject,
+
}
+
}
+1 -1
models/models.go
···
// - [X] GraphBlock *
// - [ ] GraphFollow
// - [X] GraphList *
-
// - [ ] GraphListblock *
+
// - [X] GraphListblock *
// - [ ] GraphListitem *
// - [ ] GraphStarterpack *
// - [ ] GraphVerification *