A locally focused bluesky appview
26
fork

Configure Feed

Select the types of activity you want to include in your feed.

at 066dd3fa88a8f83add9ba09f192150a94d1a0ff4 67 lines 1.5 kB view raw
1package main 2 3import ( 4 "bytes" 5 "context" 6 "fmt" 7 8 "github.com/bluesky-social/indigo/api/atproto" 9 "github.com/bluesky-social/indigo/api/bsky" 10 "github.com/bluesky-social/indigo/atproto/syntax" 11 "github.com/bluesky-social/indigo/xrpc" 12 "github.com/ipfs/go-cid" 13 "github.com/labstack/gommon/log" 14) 15 16func (s *Server) addMissingProfile(ctx context.Context, did string) { 17 select { 18 case s.missingProfiles <- did: 19 case <-ctx.Done(): 20 } 21} 22 23func (s *Server) missingProfileFetcher() { 24 for did := range s.missingProfiles { 25 if err := s.fetchMissingProfile(context.TODO(), did); err != nil { 26 log.Warn("failed to fetch missing profile", "did", did, "error", err) 27 } 28 } 29} 30 31func (s *Server) fetchMissingProfile(ctx context.Context, did string) error { 32 repo, err := s.backend.getOrCreateRepo(ctx, did) 33 if err != nil { 34 return err 35 } 36 37 resp, err := s.dir.LookupDID(ctx, syntax.DID(did)) 38 if err != nil { 39 return err 40 } 41 42 c := &xrpc.Client{ 43 Host: resp.PDSEndpoint(), 44 } 45 46 rec, err := atproto.RepoGetRecord(ctx, c, "", "app.bsky.actor.profile", did, "self") 47 if err != nil { 48 return err 49 } 50 51 prof, ok := rec.Value.Val.(*bsky.ActorProfile) 52 if !ok { 53 return fmt.Errorf("record we got back wasnt a profile somehow") 54 } 55 56 buf := new(bytes.Buffer) 57 if err := prof.MarshalCBOR(buf); err != nil { 58 return err 59 } 60 61 cc, err := cid.Decode(*rec.Cid) 62 if err != nil { 63 return err 64 } 65 66 return s.backend.HandleUpdateProfile(ctx, repo, "self", "", buf.Bytes(), cc) 67}