Skip to main content

Module wallpaper

Module wallpaper 

Source
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§

WallpaperPreview

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 a WallpaperChanged system event, and emits wallpaper_updated to 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 WallpaperChanged system event, and emits wallpaper_updated to the frontend.
remove_wallpaper
Remove the chat’s wallpaper, reverting both sides to the default theme. Publishes a kind-30078 vector-wallpaper tombstone (no url tag) so the recipient and our other devices clear it too (latest-write-wins by created_at), then DELETEs our blob and wipes local STATE/DB.