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.
74 lines
2.6 KiB
Dart
74 lines
2.6 KiB
Dart
import 'package:flutter_test/flutter_test.dart';
|
||
import 'package:tane/security/secret_store.dart';
|
||
import 'package:tane/services/social_settings.dart';
|
||
|
||
/// In-memory [SecretStore] for tests.
|
||
class FakeSecretStore implements SecretStore {
|
||
final Map<String, String> _data = {};
|
||
@override
|
||
Future<String?> read(String key) async => _data[key];
|
||
@override
|
||
Future<void> write(String key, String value) async => _data[key] = value;
|
||
}
|
||
|
||
void main() {
|
||
late SocialSettings settings;
|
||
setUp(() => settings = SocialSettings(FakeSecretStore()));
|
||
|
||
test('defaults: empty area, but relays fall back to the defaults', () async {
|
||
expect(await settings.areaGeohash(), '');
|
||
expect(await settings.relayUrls(), SocialSettings.defaultRelays);
|
||
// Not configured yet: the area is still unset.
|
||
expect(await settings.isConfigured, isFalse);
|
||
});
|
||
|
||
test('an explicitly empty relay choice turns the network off', () async {
|
||
await settings.setRelayUrls(const []);
|
||
expect(await settings.relayUrls(), isEmpty);
|
||
});
|
||
|
||
test('stores and normalises the area geohash (trim + lowercase)', () async {
|
||
await settings.setAreaGeohash(' SP3E9 ');
|
||
expect(await settings.areaGeohash(), 'sp3e9');
|
||
});
|
||
|
||
test('stores relay urls, dropping blanks', () async {
|
||
await settings.setRelayUrls([
|
||
'wss://relay.comunes.org',
|
||
' ',
|
||
'wss://seeds.example.org',
|
||
]);
|
||
expect(await settings.relayUrls(),
|
||
['wss://relay.comunes.org', 'wss://seeds.example.org']);
|
||
});
|
||
|
||
test('is configured once an area is set (relays are defaulted)', () async {
|
||
expect(await settings.isConfigured, isFalse); // no area yet
|
||
await settings.setAreaGeohash('sp3e9');
|
||
expect(await settings.isConfigured, isTrue);
|
||
});
|
||
|
||
test('search precision defaults to 4 (a wide "around here")', () async {
|
||
expect(await settings.searchPrecision(), 4);
|
||
});
|
||
|
||
test('stores and reads back the search precision', () async {
|
||
await settings.setSearchPrecision(3);
|
||
expect(await settings.searchPrecision(), 3);
|
||
await settings.setSearchPrecision(5);
|
||
expect(await settings.searchPrecision(), 5);
|
||
});
|
||
|
||
test('search precision is clamped to the 3–5 range', () async {
|
||
await settings.setSearchPrecision(1);
|
||
expect(await settings.searchPrecision(), 3);
|
||
await settings.setSearchPrecision(9);
|
||
expect(await settings.searchPrecision(), 5);
|
||
});
|
||
|
||
test('a corrupt stored precision falls back to the default', () async {
|
||
final store = FakeSecretStore();
|
||
await store.write('tane.social.search_precision', 'oops');
|
||
expect(await SocialSettings(store).searchPrecision(), 4);
|
||
});
|
||
}
|