this repo has no description
1--- a/appview/pages/funcmap.go
2+++ b/appview/pages/funcmap.go
3@@ -505,34 +505,26 @@
4 did = identity.DID.String()
5 }
6
7- secret := p.avatar.SharedSecret
8- h := hmac.New(sha256.New, []byte(secret))
9- h.Write([]byte(did))
10- signature := hex.EncodeToString(h.Sum(nil))
11-
12- // Get avatar CID for cache busting
13+ // Get avatar CID from profile DB
14 profile, err := db.GetProfile(p.db, did)
15- version := ""
16- if err == nil && profile != nil && profile.Avatar != "" {
17- // Use first 8 chars of avatar CID as version
18- if len(profile.Avatar) > 8 {
19- version = profile.Avatar[:8]
20- } else {
21- version = profile.Avatar
22+ if err == nil && profile != nil && profile.Avatar != "" && identity != nil {
23+ // Get PDS endpoint from DID document
24+ if svc, ok := identity.Services["atproto_pds"]; ok {
25+ pdsUrl := strings.TrimRight(svc.URL, "/")
26+ return fmt.Sprintf("%s/xrpc/com.atproto.sync.getBlob?did=%s&cid=%s", pdsUrl, did, profile.Avatar)
27 }
28 }
29
30- baseUrl := fmt.Sprintf("%s/%s/%s", p.avatar.Host, signature, did)
31- if size != "" {
32- if version != "" {
33- return fmt.Sprintf("%s?size=%s&v=%s", baseUrl, size, version)
34- }
35- return fmt.Sprintf("%s?size=%s", baseUrl, size)
36+ // Fallback to avatar proxy if configured
37+ if p.avatar.Host != "" && p.avatar.SharedSecret != "" {
38+ secret := p.avatar.SharedSecret
39+ h := hmac.New(sha256.New, []byte(secret))
40+ h.Write([]byte(did))
41+ signature := hex.EncodeToString(h.Sum(nil))
42+ return fmt.Sprintf("%s/%s/%s", p.avatar.Host, signature, did)
43 }
44- if version != "" {
45- return fmt.Sprintf("%s?v=%s", baseUrl, version)
46- }
47- return baseUrl
48+
49+ return ""
50 }
51
52 func (p *Pages) icon(name string, classes []string) (template.HTML, error) {