Nostr profile editor improvements #272

Merged
raucao merged 7 commits from feature/nostr-profile-fields into master 2026-11-19 20:16:23 +00:00
Owner

The Nostr profile editor in the account settings has grown from three fields into a fuller editor. This branch adds the missing kind-0 fields, lets users replace their avatar and header image (cropped server-side and uploaded to Blossom), and cleans up a few rough edges.

What's included

  • More kind-0 fields. about (bio) and website are now editable. The display name reads and writes every popular variant (display_name, displayName, name, username), and a profile with no usable picture gets the account avatar's public URL written into it on save.
  • Avatar and header image editing. Each has an "Edit" affordance over the preview. An image is uploaded to akkounts, cropped server-side (avatar 400×400, header 1500×500), and shown as the preview; animated GIFs pass through untouched, EXIF/GPS is stripped, and transparency is flattened to white. Saving the profile signs a kind-24242 Blossom upload token with the browser's NIP-07 key, and the app uploads the stored bytes to the configured Blossom server, writing the returned URLs into the kind-0 content.
  • Clearer save feedback. The save-time error sits inline with the Save button on desktop and above it on mobile, and the publish endpoint now returns and logs the specific rejection reason (public key mismatch, stale created_at, invalid id/signature, …) instead of a generic "Invalid event".
  • Layout & housekeeping. The editor uses a responsive two-column layout; the CSRF-token lookup is a shared lib/csrf.js helper; upload caps are per field (1 MB avatar, 2 MB header).

Notes and limitations

  • Image processing is server-side (Rails/Vips), so uploads work over plain-HTTP origins with no Web Crypto dependency. Uploaded images are stored on akkounts as one pending attachment per field until the profile is saved or the image is replaced.
  • An image flushed to Blossom but whose profile is never published is left orphaned on the Blossom server; Blossom dedupes by hash, so re-saving is free.
  • Requires a configured Blossom server URL (admin → Services → Nostr); the edit affordances are hidden otherwise.

Testing

bundle exec rspec — 533 examples, 0 failures. New coverage: the image processor (crop dimensions, GIF passthrough, alpha handling), the store endpoint (crop, per-field caps, types, rate limit, preview route), and the flush endpoint (multiple fields, uncovered hashes, 409 dedupe, partial-failure hard-fail).

The Nostr profile editor in the account settings has grown from three fields into a fuller editor. This branch adds the missing kind-0 fields, lets users replace their avatar and header image (cropped server-side and uploaded to Blossom), and cleans up a few rough edges. ## What's included - **More kind-0 fields.** `about` (bio) and `website` are now editable. The display name reads and writes every popular variant (`display_name`, `displayName`, `name`, `username`), and a profile with no usable `picture` gets the account avatar's public URL written into it on save. - **Avatar and header image editing.** Each has an "Edit" affordance over the preview. An image is uploaded to akkounts, cropped server-side (avatar 400×400, header 1500×500), and shown as the preview; animated GIFs pass through untouched, EXIF/GPS is stripped, and transparency is flattened to white. Saving the profile signs a kind-24242 Blossom upload token with the browser's NIP-07 key, and the app uploads the stored bytes to the configured Blossom server, writing the returned URLs into the kind-0 content. - **Clearer save feedback.** The save-time error sits inline with the Save button on desktop and above it on mobile, and the publish endpoint now returns and logs the specific rejection reason (public key mismatch, stale `created_at`, invalid id/signature, …) instead of a generic "Invalid event". - **Layout & housekeeping.** The editor uses a responsive two-column layout; the CSRF-token lookup is a shared `lib/csrf.js` helper; upload caps are per field (1 MB avatar, 2 MB header). ## Notes and limitations - Image processing is server-side (Rails/Vips), so uploads work over plain-HTTP origins with no Web Crypto dependency. Uploaded images are stored on akkounts as one pending attachment per field until the profile is saved or the image is replaced. - An image flushed to Blossom but whose profile is never published is left orphaned on the Blossom server; Blossom dedupes by hash, so re-saving is free. - Requires a configured Blossom server URL (admin → Services → Nostr); the edit affordances are hidden otherwise. ## Testing `bundle exec rspec` — 533 examples, 0 failures. New coverage: the image processor (crop dimensions, GIF passthrough, alpha handling), the store endpoint (crop, per-field caps, types, rate limit, preview route), and the flush endpoint (multiple fields, uncovered hashes, 409 dedupe, partial-failure hard-fail).
raucao added 1 commit 2026-11-19 13:49:45 +00:00
The profile editor only covered display name, NIP-05 and Lightning address. Add the bio (`about`) and `website` fields, read from the existing profile and written back on save (with `website` validated as an http(s) URL).

Lay the form out in a responsive two-column grid (single column on mobile) and align the submit button with the other account settings forms. Also fix the avatar size utility (`size:28` -> `size-28`), which left the avatar unsized on small screens and let it overlap the display-name label.

Avatar and banner image editing is still to come.
raucao added the
integration
nostr
enhancement
labels 2026-11-19 13:50:26 +00:00
raucao added 2 commits 2026-11-19 14:51:00 +00:00
When the published profile has no usable `picture` (missing, blank, or not an http(s) URL), the editor previews the account avatar and writes its public URL into the profile on save. An existing valid picture is left untouched.

The component exposes the account avatar URL to the Stimulus controller, which applies it in `content()` only when `picture` is absent or not a URL, so the preview and the published content agree.
The save-time error (e.g. a rejected signature) sat on its own line above the button. Move it into the footer row: at the start of the line and vertically centered on desktop, and on the line above the full-width button on mobile.
raucao added 1 commit 2026-11-19 15:27:26 +00:00
Report and log why a Nostr event is rejected
CI / Test (pull_request) Successful in 48s
0901e76dee
The publish endpoint collapsed every validation failure into a generic "Invalid event", making a real-world rejection impossible to diagnose. Return and log the specific reason instead: public key mismatch, non-integer created_at/kind, disallowed kind, invalid id/signature, stale created_at, content/tags too large, or a malformed request.
raucao added 3 commits 2026-11-19 17:58:24 +00:00
Four controllers each read the csrf-token meta tag themselves. Move the lookup into lib/csrf.js and import it, ahead of the profile image upload controller that also needs it.
Add a server-side API for avatar and header images: uploads are cropped with Vips (400x400 and 1500x500, GIFs passed through, EXIF stripped, transparency flattened to white) and stored as one pending attachment per field. Saving the profile flushes them to the configured Blossom server, authorized by a user-signed kind-24242 token whose x tags cover the stored hashes.
Upload avatar and header images from the Nostr profile editor
CI / Test (pull_request) Successful in 49s
Release Drafter / Update release notes draft (pull_request) Successful in 37s
be133af6fa
The editor gains edit affordances over the avatar and header image and an upload panel that stores the image (previewing the server-cropped result) and records it as pending. Saving the profile signs a Blossom upload token, flushes the pending images, merges the returned URLs into the kind-0 content, and keeps pending state until the publish succeeds so a retry re-flushes.
raucao marked the pull request as ready for review 2026-11-19 18:04:36 +00:00
raucao requested review from greg 2026-11-19 18:04:41 +00:00
raucao changed title from Add about and website fields to the Nostr profile editor to Nostr profile editor: about/website fields and avatar/header image uploads 2026-11-19 18:05:28 +00:00
raucao changed title from Nostr profile editor: about/website fields and avatar/header image uploads to Nostr profile editor improvements 2026-11-19 18:06:03 +00:00
raucao added the kredits-2 label 2026-11-19 18:06:09 +00:00
raucao removed review request for greg 2026-11-19 20:16:03 +00:00
raucao merged commit 71bc52e97e into master 2026-11-19 20:16:23 +00:00
raucao deleted branch feature/nostr-profile-fields 2026-11-19 20:16:35 +00:00
greg left a comment
Owner

👍

👍
Sign in to join this conversation.