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:
parent
11b242edbf
commit
0e7faaeb90
15 changed files with 560 additions and 15 deletions
|
|
@ -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'));
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue