Fetch identity profiles from outbox relays and render their avatars #1

Closed
opened 2026-11-28 12:03:16 +00:00 by raucao · 1 comment
Owner

Today store::profiles fetches kind-0 only from Regent's configured relays — which are NIP-46 relays, so a profile is often absent — caches just display_name, and ignores the picture. Identity avatars are therefore initials only, while a client application's icon is fetched, cached and rendered.

The profile fetch should also look at the identity's own relays, and the picture should be stored and rendered like a client app icon.

Fetch

  • Query the identity's NIP-65 relay list (kind:10002) as well, and fetch kind-0 from its write relays (or all of them) in addition to our relays.
  • Keep the newest kind-0 by created_at across every relay: kind-0 is replaceable, so a relay serves its own latest, but the newest overall is what should win. The current fetch already keeps the newest per author.
  • Parse picture into the cached Profile (trimmed, empty treated as absent, bounded to 256 chars like ClientInfo.image), and add a picture(key) accessor.

Storage

  • Fetch the picture bytes through the existing hardened IconStore path — https or inline data: only, public-address check, redirect re-validation, 5 s timeout, 1 MiB cap, magic-byte format gate (png/jpeg/gif/webp; no SVG). Add AppState::hydrate_avatar/load_avatar next to hydrate_icon/load_icon.
  • Extend the icon gc live set to AppRegistry::client_keys() plus every identity pubkey: today apps_view reaps against client keys only, which would delete identity avatars on any Apps-page rebuild.
  • Fetch unconditionally rather than under load-app-icons — it is the user's own identity, not an untrusted client. Note the leak this implies: the picture fetch reveals the identity's picture URL (and the machine's address) to that host, the same as the profile fetch already does to the relays.

Rendering

  • plain::avatar/plain::set_avatar already take an optional gdk::Texture and are wired into the switcher, the keys list, the approval and Connect dialogs and the Apps page's "Signing as" row, so the texture lookup lights up once the fetch lands. The approval dialog needs the swap-in callback (as preview_icon does for a client icon), since it is built per question.

Library note

nostr::nips::nip65 has RelayList, RelayMetadata::{Read,Write} and extract_relay_list(&Event), plus Kind::RelayList (10002), so parsing the list is one call. The SDK's gossip will route an author filter to the author's write relays for you (Client::builder().gossip(NostrGossipMemory::unbounded())), but it needs a gossip store dependency and discovery relays, and Regent's profile client is deliberately ephemeral with manual (RelayUrl, Vec<Filter>) targets (a #p-only filter otherwise resolves to no relay). The two-stage fetch fits our shape better.

Today `store::profiles` fetches kind-0 only from Regent's configured relays — which are NIP-46 relays, so a profile is often absent — caches just `display_name`, and ignores the `picture`. Identity avatars are therefore initials only, while a client application's icon is fetched, cached and rendered. The profile fetch should also look at the identity's own relays, and the picture should be stored and rendered like a client app icon. ## Fetch - Query the identity's NIP-65 relay list (kind:10002) as well, and fetch kind-0 from its write relays (or all of them) in addition to our relays. - Keep the newest kind-0 by `created_at` across every relay: kind-0 is replaceable, so a relay serves its own latest, but the newest overall is what should win. The current fetch already keeps the newest per author. - Parse `picture` into the cached `Profile` (trimmed, empty treated as absent, bounded to 256 chars like `ClientInfo.image`), and add a `picture(key)` accessor. ## Storage - Fetch the picture bytes through the existing hardened `IconStore` path — https or inline `data:` only, public-address check, redirect re-validation, 5 s timeout, 1 MiB cap, magic-byte format gate (png/jpeg/gif/webp; no SVG). Add `AppState::hydrate_avatar`/`load_avatar` next to `hydrate_icon`/`load_icon`. - Extend the icon `gc` live set to `AppRegistry::client_keys()` **plus** every identity pubkey: today `apps_view` reaps against client keys only, which would delete identity avatars on any Apps-page rebuild. - Fetch unconditionally rather than under `load-app-icons` — it is the user's own identity, not an untrusted client. Note the leak this implies: the picture fetch reveals the identity's picture URL (and the machine's address) to that host, the same as the profile fetch already does to the relays. ## Rendering - `plain::avatar`/`plain::set_avatar` already take an optional `gdk::Texture` and are wired into the switcher, the keys list, the approval and Connect dialogs and the Apps page's "Signing as" row, so the texture lookup lights up once the fetch lands. The approval dialog needs the swap-in callback (as `preview_icon` does for a client icon), since it is built per question. ## Library note `nostr::nips::nip65` has `RelayList`, `RelayMetadata::{Read,Write}` and `extract_relay_list(&Event)`, plus `Kind::RelayList` (10002), so parsing the list is one call. The SDK's gossip will route an author filter to the author's write relays for you (`Client::builder().gossip(NostrGossipMemory::unbounded())`), but it needs a gossip store dependency and discovery relays, and Regent's profile client is deliberately ephemeral with manual `(RelayUrl, Vec<Filter>)` targets (a `#p`-only filter otherwise resolves to no relay). The two-stage fetch fits our shape better.
raucao added the feature label 2026-11-28 12:04:48 +00:00
Author
Owner

Done.

Done.
Sign in to join this conversation.