From c95b0836be93189794a03745ae823484559a390e Mon Sep 17 00:00:00 2001 From: dbth <1097224+believethehype@users.noreply.github.com> Date: Thu, 6 Feb 2025 20:35:11 +0100 Subject: [PATCH] write to own relays, too. --- .gitignore | 1 + nostr_dvm/tasks/discovery_inactive_follows.py | 3 +++ nostr_dvm/utils/nostr_utils.py | 11 +++-------- 3 files changed, 7 insertions(+), 8 deletions(-) diff --git a/.gitignore b/.gitignore index 156d1f1..6de185d 100644 --- a/.gitignore +++ b/.gitignore @@ -200,3 +200,4 @@ tests/gifs/data.mdb tests/gifs/lock.mdb tests/gif_library.py /.idea +/.idea diff --git a/nostr_dvm/tasks/discovery_inactive_follows.py b/nostr_dvm/tasks/discovery_inactive_follows.py index 6bf69cb..071c18e 100644 --- a/nostr_dvm/tasks/discovery_inactive_follows.py +++ b/nostr_dvm/tasks/discovery_inactive_follows.py @@ -23,6 +23,9 @@ Params: None """ +# TODO: This is currently broken after SDK update. + + class DiscoverInactiveFollows(DVMTaskInterface): KIND: Kind = EventDefinitions.KIND_NIP90_PEOPLE_DISCOVERY TASK: str = "inactive-followings" diff --git a/nostr_dvm/utils/nostr_utils.py b/nostr_dvm/utils/nostr_utils.py index 8a8be86..acff95d 100644 --- a/nostr_dvm/utils/nostr_utils.py +++ b/nostr_dvm/utils/nostr_utils.py @@ -178,7 +178,7 @@ async def get_main_relays(event_to_send: Event, client: Client, dvm_config): async def send_event_outbox(event: Event, client, dvm_config) -> SendEventOutput | None: # 1. OK, Let's overcomplicate things. # 2. If our event has a relays tag, we just send the event to these relay in the classical way. - relays = [] + relays = dvm_config.RELAY_LIST for tag in event.tags().to_vec(): if tag.as_vec()[0] == 'relays': for index, param in enumerate(tag.as_vec()): @@ -192,20 +192,15 @@ async def send_event_outbox(event: Event, client, dvm_config) -> SendEventOutput break # 3. If we couldn't find relays, we look in the receivers inbox - if len(relays) == 0: + if len(relays) == len(dvm_config.RELAY_LIST): relays = await get_inbox_relays(event, client, dvm_config) # 4. If we don't find inbox relays (e.g. because the user didn't announce them, we just send to our default relays - if len(relays) == 0: + if len(relays) == len(dvm_config.RELAY_LIST): print("[" + dvm_config.NIP89.NAME + "] No Inbox found, replying to generic relays") relays = await get_main_relays(event, client, dvm_config) - if len(relays) == 0: - return - # eventid = await send_event(event, client, dvm_config) - # return eventid - # 5. Otherwise, we create a new Outbox client with the inbox relays and send the event there relaylimits = RelayLimits.disable() connection = Connection().addr("127.0.0.1:9050").target(ConnectionTarget.ONION)