feat(market): embed offer photos inline instead of a media server

Replace the Blossom media-server approach with a fully decentralized one:
generate a small (~320px) JPEG thumbnail from the lot's cover photo and
embed it in the offer event as a data: URI, so photos ride the relays with
no server and no IP leak. The full photo stays in the encrypted inventory.

- offer_thumbnail.dart: downscale-until-it-fits data-URI builder + decoder
- market_widgets: render data: URIs from memory, http(s) URLs from network
- offers_cubit: publish a thumbnail (best-effort) in place of an upload
- drop MediaTransport/Blossom from commons_core (http/crypto deps) and the
  media-server setting; parked on branch parked/offer-photos-blossom

Relay event-size limits cap the image to a thumbnail; higher-res sharing
would need the parked Blossom path.
This commit is contained in:
vjrj 2026-07-10 21:27:59 +02:00
parent 5017ea51e0
commit 2b419e6516
24 changed files with 230 additions and 411 deletions

View file

@ -17,7 +17,6 @@ class SocialSettings {
static const _areaKey = 'tane.social.area_geohash';
static const _relaysKey = 'tane.social.relays';
static const _searchPrecisionKey = 'tane.social.search_precision';
static const _mediaServerKey = 'tane.social.media_server';
/// How wide "your zone" searches, as a geohash prefix length: 5 ±2.4 km
/// ("very close"), 4 ±20 km ("around here"), 3 ±78 km ("my region").
@ -40,11 +39,6 @@ class SocialSettings {
'wss://relay.primal.net',
];
/// Blossom media server used to host offer photos so peers can see them. The
/// Comunes-run server is the non-commercial default; the user can point this
/// at any Blossom server, or clear it to publish offers without photos.
static const String defaultMediaServer = 'https://blossom.comunes.org';
/// The user's coarse area as a low-precision geohash (may be empty). Set
/// manually or from device location; the transport coarsens it further.
Future<String> areaGeohash() async => (await _store.read(_areaKey)) ?? '';
@ -79,18 +73,6 @@ class SocialSettings {
Future<void> setSearchPrecision(int precision) =>
_store.write(_searchPrecisionKey, '${_clampPrecision(precision)}');
/// The Blossom media server for offer photos. Falls back to
/// [defaultMediaServer] until the user configures one; an explicitly saved
/// empty value turns photo hosting off (offers still publish, without images).
Future<String> mediaServerUrl() async {
final raw = await _store.read(_mediaServerKey);
if (raw == null) return defaultMediaServer; // never configured
return raw.trim();
}
Future<void> setMediaServerUrl(String url) =>
_store.write(_mediaServerKey, url.trim());
int _clampPrecision(int p) => p < minSearchPrecision
? minSearchPrecision
: (p > maxSearchPrecision ? maxSearchPrecision : p);