From cc13401e1478e51bfe9a33a2e1f35d2811c9bc5a Mon Sep 17 00:00:00 2001 From: Believethehype <1097224+believethehype@users.noreply.github.com> Date: Sat, 7 Dec 2024 16:23:40 +0100 Subject: [PATCH] Olas DVM: also look for kind 1111 replies (NIP22) --- ...ntent_discovery_currently_popular_gallery.py | 17 +++++++++++++++-- nostr_dvm/utils/definitions.py | 1 + tests/discovery_gallery.py | 8 ++++---- 3 files changed, 20 insertions(+), 6 deletions(-) diff --git a/nostr_dvm/tasks/content_discovery_currently_popular_gallery.py b/nostr_dvm/tasks/content_discovery_currently_popular_gallery.py index cba6ce1..ccea6e8 100644 --- a/nostr_dvm/tasks/content_discovery_currently_popular_gallery.py +++ b/nostr_dvm/tasks/content_discovery_currently_popular_gallery.py @@ -5,7 +5,7 @@ from datetime import timedelta from nostr_sdk import Timestamp, Tag, Keys, Options, SecretKey, NostrSigner, NostrDatabase, \ ClientBuilder, Filter, SyncOptions, SyncDirection, init_logger, LogLevel, EventId, Kind, \ - RelayLimits + RelayLimits, SingleLetterTag, Alphabet from nostr_dvm.interfaces.dvmtaskinterface import DVMTaskInterface, process_venv from nostr_dvm.utils import definitions @@ -150,8 +150,16 @@ class DicoverContentCurrentlyPopularGallery(DVMTaskInterface): definitions.EventDefinitions.KIND_DELETION, definitions.EventDefinitions.KIND_NOTE]).events(ids).since(since) + ids_str = [] + for id in ids: + ids_str.append(id.to_hex()) + + filter_nip22 = Filter().kinds([definitions.EventDefinitions.KIND_NIP22_COMMENT]).custom_tag(SingleLetterTag.uppercase(Alphabet.E), + ids_str).since(since) + dbopts = SyncOptions().direction(SyncDirection.DOWN) await cli.sync(filtreactions, dbopts) + await cli.sync(filter_nip22, dbopts) filter2 = Filter().ids(ids) events = await cli.fetch_events([filter2], relay_timeout) @@ -169,7 +177,12 @@ class DicoverContentCurrentlyPopularGallery(DVMTaskInterface): filt = Filter().kinds([definitions.EventDefinitions.KIND_ZAP, definitions.EventDefinitions.KIND_REPOST, definitions.EventDefinitions.KIND_REACTION, definitions.EventDefinitions.KIND_NOTE]).event(event.id()).since(since) - reactions = await databasegallery.query([filt]) + + filter_nip22 = Filter().kinds([definitions.EventDefinitions.KIND_NIP22_COMMENT]).custom_tag( + SingleLetterTag.uppercase(Alphabet.E), + [event.id().to_hex()]) + + reactions = await databasegallery.query([filt, filter_nip22]) #print("Reactions:" + str(len(reactions.to_vec()))) if len(reactions.to_vec()) >= self.min_reactions: diff --git a/nostr_dvm/utils/definitions.py b/nostr_dvm/utils/definitions.py index b79b7da..c1656a9 100644 --- a/nostr_dvm/utils/definitions.py +++ b/nostr_dvm/utils/definitions.py @@ -14,6 +14,7 @@ class EventDefinitions: KIND_REACTION = Kind(7) KIND_NIP68_IMAGEEVENT = Kind(20) KIND_NIP94_METADATA = Kind(1063) + KIND_NIP22_COMMENT = Kind(1111) KIND_NIP93_GALLERYENTRY = Kind(1163) KIND_NIP90_EXTRACT_TEXT = Kind(5000) KIND_NIP90_RESULT_EXTRACT_TEXT = Kind(6000) diff --git a/tests/discovery_gallery.py b/tests/discovery_gallery.py index 100e1ba..89761b8 100644 --- a/tests/discovery_gallery.py +++ b/tests/discovery_gallery.py @@ -9,9 +9,9 @@ from nostr_dvm.utils.admin_utils import AdminConfig from nostr_dvm.utils.dvmconfig import build_default_config from nostr_dvm.utils.nip89_utils import create_amount_tag, NIP89Config, check_and_set_d_tag -rebroadcast_NIP89 = True # Announce NIP89 on startup +rebroadcast_NIP89 = False # Announce NIP89 on startup rebroadcast_NIP65_Relay_List = False -update_profile = True +update_profile = False global_update_rate = 500 # set this high on first sync so db can fully sync before another process trys to. use_logger = True @@ -69,8 +69,8 @@ def playground(): update_db = True options_gallery = { - "db_name": "db/nostr_gallery.db", - "db_since": 60 * 60 * 24 * 2, # 2d since gmt, + "db_name": "db/nostr_olas.db", + "db_since": 60 * 60 * 24 * 4, # 2d since gmt, }