Live video on the AT Protocol
79
fork

Configure Feed

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

at natb/loading-overlay 48 lines 1.1 kB view raw
1package discord 2 3import ( 4 "context" 5 "fmt" 6 "sync" 7 8 "github.com/bluesky-social/indigo/api/bsky" 9 "github.com/bluesky-social/indigo/xrpc" 10 "stream.place/streamplace/pkg/aqhttp" 11 "stream.place/streamplace/pkg/model" 12) 13 14var avatarCache = make(map[string]string) 15var avatarCacheMutex = sync.Mutex{} 16 17// getAvatarURL gets the avatar URL for a Bluesky from the public appview 18// pretty ugly. we're going to replace this with indexing bluesky profiles 19// at some point. 20func getAvatarURL(ctx context.Context, r *model.Repo) (string, error) { 21 avatarCacheMutex.Lock() 22 defer avatarCacheMutex.Unlock() 23 24 if r == nil || r.DID == "" { 25 return "", fmt.Errorf("repo or DID is nil or empty") 26 } 27 28 if avatar, ok := avatarCache[r.DID]; ok { 29 return avatar, nil 30 } 31 32 xrpc := &xrpc.Client{ 33 Host: "https://public.api.bsky.app", 34 Client: &aqhttp.Client, 35 } 36 37 profile, err := bsky.ActorGetProfile(ctx, xrpc, r.DID) 38 if err != nil { 39 return "", err 40 } 41 42 if profile.Avatar != nil { 43 avatarCache[r.DID] = *profile.Avatar 44 return *profile.Avatar, nil 45 } 46 47 return "", nil 48}