an app.bsky.* indexer

add GraphVerification

Changed files
+47 -1
cmd
monarch
models
+7
cmd/monarch/handlers.go
···
&models.GraphListblock{},
&models.GraphListitem{},
&models.GraphStarterpack{},
}
for _, migration := range migrations {
store.AutoMigrate(migration)
···
pack := models.NewGraphStarterpack(uri, *rec)
if err := hs.store.Where(models.GraphStarterpack{ID: string(uri)}).Assign(pack).FirstOrCreate(&models.GraphStarterpack{}).Error; err != nil {
return fmt.Errorf("error upserting graph starterpack: %w", err)
}
}
···
&models.GraphListblock{},
&models.GraphListitem{},
&models.GraphStarterpack{},
+
&models.GraphVerification{},
}
for _, migration := range migrations {
store.AutoMigrate(migration)
···
pack := models.NewGraphStarterpack(uri, *rec)
if err := hs.store.Where(models.GraphStarterpack{ID: string(uri)}).Assign(pack).FirstOrCreate(&models.GraphStarterpack{}).Error; err != nil {
return fmt.Errorf("error upserting graph starterpack: %w", err)
+
}
+
+
case syntax.NSID("app.bsky.graph.verification"):
+
verification := models.NewGraphVerification(uri, *rec)
+
if err := hs.store.Where(models.GraphVerification{ID: string(uri)}).Assign(verification).FirstOrCreate(&models.GraphVerification{}).Error; err != nil {
+
return fmt.Errorf("error upserting graph verification: %w", err)
}
}
+39
models/graph_verification.go
···
···
+
package models
+
+
import (
+
"bytes"
+
"log/slog"
+
"time"
+
+
appbsky "github.com/bluesky-social/indigo/api/bsky"
+
"github.com/bluesky-social/indigo/atproto/syntax"
+
)
+
+
type GraphVerification struct {
+
ID string `gorm:"primaryKey"`
+
+
CreatedAt string
+
DisplayName string
+
Handle string
+
Subject string
+
+
AutoCreatedAt time.Time `gorm:"autoCreateTime"`
+
AutoUpdatedAt time.Time `gorm:"autoUpdateTime"`
+
}
+
+
func NewGraphVerification(uri syntax.ATURI, rec []byte) *GraphVerification {
+
var out appbsky.GraphVerification
+
if err := out.UnmarshalCBOR(bytes.NewReader(rec)); err != nil {
+
slog.Error("could not unmarshal graph verification CBOR", "err", err)
+
return nil
+
}
+
+
verification := GraphVerification{
+
CreatedAt: out.CreatedAt,
+
DisplayName: out.DisplayName,
+
Handle: out.Handle,
+
Subject: out.Subject,
+
}
+
+
return &verification
+
}
+1 -1
models/models.go
···
// - [X] GraphListblock *
// - [X] GraphListitem *
// - [X] GraphStarterpack *
-
// - [ ] GraphVerification *
// - [ ] LabelerService *
// - [ ] ActorDeclaration
// - [ ] LexiconSchema *
···
// - [X] GraphListblock *
// - [X] GraphListitem *
// - [X] GraphStarterpack *
+
// - [X] GraphVerification *
// - [ ] LabelerService *
// - [ ] ActorDeclaration
// - [ ] LexiconSchema *