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

@ -39,34 +39,20 @@ class SocialService {
/// Opens a session against [relayUrls]: one fault-tolerant pool carrying all
/// three transports (offers, messaging, trust). Relays that are down are
/// skipped; throws only when none are reachable. Caller closes it.
///
/// [mediaServerUrl] (a Blossom endpoint) enables offer photos: when set, the
/// session exposes a [MediaTransport] to host images. It rides HTTP, not the
/// relay pool, so it's independent of relay reachability.
Future<SocialSession> openSession(
List<String> relayUrls, {
String? mediaServerUrl,
}) async {
Future<SocialSession> openSession(List<String> relayUrls) async {
final pool = await RelayPool.connect(relayUrls, identity: identity);
return SocialSession(pool, mediaServerUrl: mediaServerUrl);
return SocialSession(pool);
}
}
/// One relay channel with the three transports on top the
/// "one channel, three interfaces" shape, at the app layer. Media rides its own
/// HTTP endpoint (Blossom), so it's a fourth transport but not on the channel.
/// "one channel, three interfaces" shape, at the app layer.
class SocialSession {
SocialSession(this._channel, {String? mediaServerUrl})
SocialSession(this._channel)
: offers = NostrOfferTransport(_channel),
messages = NostrMessageTransport(_channel),
trust = NostrTrustTransport(_channel),
profile = NostrProfileTransport(_channel),
media = (mediaServerUrl != null && mediaServerUrl.trim().isNotEmpty)
? BlossomMediaTransport(
Uri.parse(mediaServerUrl.trim()),
_channel.privateKeyHex,
)
: null;
profile = NostrProfileTransport(_channel);
final NostrChannel _channel;
@ -75,14 +61,7 @@ class SocialSession {
final TrustTransport trust;
final ProfileTransport profile;
/// Hosts offer photos, or null when no media server is configured (offers then
/// publish without images).
final MediaTransport? media;
Future<void> close() async {
await media?.close();
await _channel.close();
}
Future<void> close() => _channel.close();
}
Uint8List _hexToBytes(String hex) {