feat(server): write gallery images and the manifest

Merged
BR
12d ago
+2936-33

Summary

Closes #9. Part of #1.

  • Adds gallery output, a switch that is off by default. On, with a public base URL, each published post also writes a clean image of the photo and an entry in posts.json, and its framed image is kept. Off, the framed image is deleted once published, as before.
  • The clean image is the photo with no frame, 2048 px on its long side and never enlarged, in sRGB, as a JPEG with no embedded metadata, under a random key.
  • posts.json lists each post's image URLs, caption, alt text, capture data, location and permalink. The format is version 1 and documented in docs/manifest.md; a test checks a written manifest against it.
  • Everything public comes from published(id). An entry for a select whose location is withheld has no coordinates in any field, and an entry is rewritten without them on the next timer run when a location is hidden or a privacy zone is added after the post: its location and framed image are removed, the framed object is deleted, and its caption and alt text become the versions built at posting time with the location withheld. A hand-written caption is listed as empty then. Locations are listed to four decimal places.
  • "Remove from gallery" deletes a post's public files and manifest entry and leaves the select posted. It finishes later if the bucket is failing.
  • The database is the source of truth: the manifest is rebuilt from it in full, an entry is listed only once its image is stored, and an image is deleted only after a manifest without it is stored. A gallery failure never fails, undoes or repeats an Instagram post.
  • Without a public base URL the switch is unavailable and Settings says why.
  • One migration adds gallery_posts. Decisions are recorded as ADR 0008.

Evidence

From the generated fixtures, in fake mode.

Posted screen showing each post's gallery state and Remove from gallery

Settings with the gallery output switch and the manifest address

A clean gallery image written for a fixture: the photo with no frame

Typecheck, lint, 398 tests and the build pass locally. In fake mode I posted two fixtures with the gallery on, read the manifest and a clean image back from the fake bucket (no metadata segments, cache headers as documented), hid a location after posting and saw the entry lose its coordinates within a timer run, and removed a post from the gallery.

Merge Danger

Medium. Gallery output is public. Cache headers are set through a presigned upload whose unsigned headers are untested against a real bucket; ADR 0008 lists this as unverified until the first live run.