A social pastebin built on atproto.
6
fork

Configure Feed

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

avatars: cry CDN, fallback properly to PDS

+17 -8
+15 -6
main.py
··· 128 128 return Response(status=404) 129 129 130 130 profile = fetch_profile(did, pds_url) 131 - avatar_url = profile.get("avatar_blob_url") 132 - if not avatar_url: 131 + cdn_url = profile.get("avatar_url") 132 + blob_url = profile.get("avatar_blob_url") 133 + if not cdn_url and not blob_url: 133 134 return Response(status=404) 134 135 135 - try: 136 - resp = requests.get(avatar_url, timeout=5) 137 - resp.raise_for_status() 138 - except requests.RequestException, ValueError: 136 + resp = None 137 + for url in [cdn_url, blob_url]: 138 + if not url: 139 + continue 140 + try: 141 + resp = requests.get(url, timeout=5) 142 + if resp.status_code == 200: 143 + break 144 + except (requests.RequestException, ValueError): 145 + continue 146 + 147 + if resp is None or resp.status_code != 200: 139 148 return Response(status=502) 140 149 141 150 content_type = resp.headers.get("Content-Type", "image/jpeg")
+1 -1
templates/list.html
··· 6 6 <!-- Profile card --> 7 7 <div class="flex items-center gap-3 mb-6 pb-5 border-b border-gray-100"> 8 8 {% if profile.avatar_url %} 9 - <img src="{{ profile.avatar_url }}" alt="" class="w-12 h-12 rounded-full"> 9 + <img src="{{ profile.avatar_url }}" onerror="this.onerror=null;this.src='/avatar/{{ did }}'" alt="" class="w-12 h-12 rounded-full"> 10 10 {% else %} 11 11 <div class="w-12 h-12 rounded-full bg-gray-100"></div> 12 12 {% endif %}
+1 -1
templates/view.html
··· 9 9 <div class="flex items-center gap-1.5"> 10 10 <a href="{{ url_for('list_bites', identifier=did) }}"> 11 11 {% if profile.avatar_url %} 12 - <img src="{{ profile.avatar_url }}" alt="" class="w-4 h-4 rounded-full"> 12 + <img src="{{ profile.avatar_url }}" onerror="this.onerror=null;this.src='/avatar/{{ did }}'" alt="" class="w-4 h-4 rounded-full"> 13 13 {% else %} 14 14 <div class="w-4 h-4 rounded-full bg-gray-100"></div> 15 15 {% endif %}