feat(social): standard NIP-56 reporting — ReportTransport in commons_core, report sheet on offers and chats, local hide + optional block

This commit is contained in:
vjrj 2026-07-13 07:56:43 +02:00
parent 11b242edbf
commit 0e7faaeb90
15 changed files with 560 additions and 15 deletions

View file

@ -18,6 +18,7 @@ class SocialSettings {
static const _relaysKey = 'tane.social.relays';
static const _searchPrecisionKey = 'tane.social.search_precision';
static const _blockedKey = 'tane.social.blocked_pubkeys';
static const _hiddenOffersKey = 'tane.social.hidden_offers';
/// 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").
@ -109,4 +110,25 @@ class SocialSettings {
..remove(pubkeyHex.trim().toLowerCase());
await _store.write(_blockedKey, set.join('\n'));
}
/// The stable key of one published offer, for the hidden-offers set.
static String offerKey(String authorPubkeyHex, String offerId) =>
'${authorPubkeyHex.trim().toLowerCase()}:$offerId';
/// Offers this user reported and no longer wants to see, as
/// [offerKey] entries. Purely local, like the blocklist.
Future<Set<String>> hiddenOfferKeys() async {
final raw = await _store.read(_hiddenOffersKey);
if (raw == null) return <String>{};
return raw.split('\n').where((s) => s.trim().isNotEmpty).toSet();
}
Future<void> hideOffer({
required String authorPubkeyHex,
required String offerId,
}) async {
final set = await hiddenOfferKeys()
..add(offerKey(authorPubkeyHex, offerId));
await _store.write(_hiddenOffersKey, set.join('\n'));
}
}