Skip to main content

Module albums

Module albums 

Source
Expand description

Album provisioning — telling the server an album exists.

A container album’s id is derived from the account master key (Organization — The Default Album), so the client knows it before the server does. This module is the one call that closes that gap: POST /v1/albums binds the derived UUID to the authenticated owner, so invariant 6 (“album exists; the caller has write capability on it”) can pass for an album the client named. Every push runs it first — crate::push::ensure_album is the step, this module is the wire.

Idempotent, and that is the whole point. The same id arrives from every device the user owns, and again after a passphrase recovery on a fresh one. Re-provisioning is a success that writes nothing (created: false), so a client needs no “have I registered this album yet?” flag — which is precisely the synced pointer the master-key derivation exists to avoid. Pushing twice therefore cannot error here.

No name crosses the wire. The request body carries the id and nothing else; album titles live in the encrypted sidecar and the server is not entitled to them.

Lifecycle ops ride here too. AlbumClient::apply_op sends one signed delete, trash-restore or other bytes-free lifecycle manifest to POST /v1/albums/{album_id}/ops and types the refusal (LifecycleOpError), so every client tells a closed retention window (retention_elapsed, final for the asset) from a stale chain or a transient fault the same way. The op’s envelope (op_envelope), which records of a chain go to the server (chain_after, stretch_after), and when they are held instead (plan_delivery) are defined here once, for every client that sends one.

Re-exports§

pub use crate::upload::StaticToken;

Structs§

AlbumClient
The album-provisioning client.
AlbumTransport
The authorized HTTP transport for the album surface: the album endpoint root (no trailing slash — POST {base} provisions) plus the authorization seam.
AppliedOp
What the server did with one lifecycle op (POST /v1/albums/{album_id}/ops).
ProvisionedAlbum
What provisioning an album resolved to. Both cases are successes; created is informational — a caller treats a fresh binding and an existing one identically.
PublishedRoster
What the server holds for an album after a roster publish.

Enums§

AlbumError
A failure on the album surface: provisioning, or publishing a roster.
HeldDelivery
What a delivery does with one asset’s chain (plan_delivery).
HoldReason
Why an asset’s records were not sent.
LifecycleOpError
Why a lifecycle op was not applied.

Functions§

chain_after
The records of records (a chain, oldest first) the server lacks when it holds head: those after it, which is none when head already is the last; or the last record alone when head is unknown or not in the chain, which the server judges (a stale chain is refused, never applied).
judging_clock
The clock a held stretch is judged by: this device’s (now), floored by the latest changed_at a feed drain saw on the server’s clock, so a restore is withheld whenever either clock says the server would refuse it. Only plan_delivery uses it: a retention sweep judges expiry by the server’s changed_at alone, since a device clock running ahead would purge early.
op_envelope
The server-visible projection of a lifecycle manifest: every field verbatim, naming the original’s ciphertext, and no derivative (the server refuses the pair on a lifecycle write).
plan_delivery
Decide what of records (an asset’s chain, oldest first) goes to the server, given what its feed lists for the asset (server: None when it does not list it, otherwise the hash of the head it holds, None for an entry that carries no record) and the judging clock (judging_clock).
stretch_after
The stretch a delivery sends when the server holds head: chain_after, except that a server level with the chain is sent the last record alone, which it answers as a replay (a send whose answer was lost). Empty only for an empty chain.