Expand description
Per-DM wallpaper feature.
Wallpapers are static images attached to a 1:1 DM conversation. Either
party may set one; latest-write-wins by rumor created_at.
On the wire: a NIP-17 gift-wrapped rumor with kind 30078 and the d tag
vector-wallpaper. The wallpaper bytes themselves are AES-256-GCM
encrypted onto Blossom — same crypto path Vector uses for normal file
attachments. The decryption key + nonce live in the rumor’s tags; that’s
safe because the rumor is already sealed inside the NIP-17 envelope
addressed only to the two participants.
Rumor shape:
kind: 30078 (APPLICATION_SPECIFIC)
created_at: now (latest-write-wins tiebreaker)
tags:
["d", "vector-wallpaper"]
["url", <blossom URL>]
["decryption-key", <hex>]
["decryption-nonce", <hex>]
["x", <plaintext sha256>]
["m", "image/png"] (optional)
["size", <encrypted size in bytes>]
content: "" (unused; metadata lives in tags)Structs§
Constants§
- MAX_
WALLPAPER_ BYTES - Maximum allowed source-image size (pre-encryption). Matches the user- facing cap; enforced both at preview prep and at the picker UI.
Functions§
- apply_
received_ wallpaper - Apply a received wallpaper rumor. Drops the rumor if its timestamp is
not newer than the chat’s current
wallpaper_ts(latest-write-wins). On a fresh rumor: downloads + decrypts the Blossom blob, caches it locally, updates STATE + DB, saves aWallpaperChangedsystem event, and emitswallpaper_updatedto the frontend. - cancel_
wallpaper_ preview - Delete the preview file (user cancelled before publishing).
- prepare_
wallpaper_ preview - Validate + prepare a picked image: enforce the 5 MB cap, image-only mime, extract first frame for animated formats, write to the per-chat preview slot. The returned path is what the chat background should switch to while the Confirm/Cancel bar is showing.
- publish_
wallpaper - Publish the current preview file as the chat’s wallpaper. Encrypts +
uploads to Blossom, builds the kind-30078 rumor, sends to the
counterparty (the gift-wrap helper fans out to self for cross-device
sync), promotes the preview file to the active slot, updates STATE +
DB, drops a
WallpaperChangedsystem event, and emitswallpaper_updatedto the frontend. - remove_
wallpaper - Remove the chat’s wallpaper, reverting both sides to the default theme.
Publishes a kind-30078
vector-wallpapertombstone (nourltag) so the recipient and our other devices clear it too (latest-write-wins bycreated_at), then DELETEs our blob and wipes local STATE/DB.