A locally focused bluesky appview
at master 1.1 kB view raw
1package hydration 2 3import ( 4 "github.com/bluesky-social/indigo/atproto/identity" 5 "github.com/whyrusleeping/konbini/backend" 6 "gorm.io/gorm" 7) 8 9// Hydrator handles data hydration from the database 10type Hydrator struct { 11 db *gorm.DB 12 dir identity.Directory 13 backend *backend.PostgresBackend 14} 15 16// NewHydrator creates a new Hydrator 17func NewHydrator(db *gorm.DB, dir identity.Directory, backend *backend.PostgresBackend) *Hydrator { 18 return &Hydrator{ 19 db: db, 20 dir: dir, 21 backend: backend, 22 } 23} 24 25// AddMissingRecord reports a missing record that needs to be fetched 26func (h *Hydrator) AddMissingRecord(identifier string, wait bool) { 27 if h.backend != nil { 28 h.backend.TrackMissingRecord(identifier, wait) 29 } 30} 31 32// addMissingActor is a convenience method for adding missing actors 33func (h *Hydrator) addMissingActor(did string) { 34 h.AddMissingRecord(did, false) 35} 36 37// HydrateCtx contains context for hydration operations 38type HydrateCtx struct { 39 Viewer string 40} 41 42// NewHydrateCtx creates a new hydration context 43func NewHydrateCtx(viewer string) *HydrateCtx { 44 return &HydrateCtx{ 45 Viewer: viewer, 46 } 47}