From 130559baf076eb7bf3bdbf497431bf3af53c23c4 Mon Sep 17 00:00:00 2001 From: franzap <_@franzap.com> Date: Wed, 8 Apr 2026 12:04:28 -0300 Subject: [PATCH] Allow zapstore pubkeys to delete local storage entries (in the future derived from catalog) --- lib/services/background_update_service.dart | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/lib/services/background_update_service.dart b/lib/services/background_update_service.dart index fd8f99a..a353984 100644 --- a/lib/services/background_update_service.dart +++ b/lib/services/background_update_service.dart @@ -206,9 +206,23 @@ Future _checkForUpdatesInBackground(Set? appCatalogRelays) async { ); await secureStorage.setDeletionsSyncedUntil(DateTime.now()); if (deletionRequests.isNotEmpty) { + // Purplebase's NIP-09 processing only deletes events whose pubkey + // matches the kind-5 author. Relay-authority deletions (blacklists) + // are signed by zapstore/community keys, not the app author, so + // those targets survive. Collect them and delete directly by ID. + const trustedAuthorities = {kZapstorePubkey, kZapstoreCommunityPubkey}; + final authorityTargetIds = deletionRequests + .where((dr) => trustedAuthorities.contains(dr.event.pubkey)) + .expand((dr) => dr.deletedEventIds) + .toSet(); + try { - await (storage as PurplebaseStorageNotifier) + final storageNotifier = storage as PurplebaseStorageNotifier; + await storageNotifier .delete(deletionRequests.map((d) => d.id).toSet()); + if (authorityTargetIds.isNotEmpty) { + await storageNotifier.delete(authorityTargetIds); + } } catch (_) { // Orphaned kind-5 rows are harmless; referenced events are // already removed by the DB layer during save.