mirror of
https://github.com/believethehype/nostrdvm.git
synced 2025-10-09 20:22:44 +02:00
catch exception for malformed relays in users relay inbox
This commit is contained in:
@@ -121,7 +121,7 @@ def get_inbox_relays(event_to_send: Event, client: Client, dvm_config):
|
|||||||
nip65event = events[0]
|
nip65event = events[0]
|
||||||
relays = []
|
relays = []
|
||||||
for tag in nip65event.tags():
|
for tag in nip65event.tags():
|
||||||
if ((tag.as_vec()[0] == 'r' and len(tag.as_vec()) == 2)
|
if ((tag.as_vec()[0] == 'r' and len(tag.as_vec()) == 2)
|
||||||
or ((tag.as_vec()[0] == 'r' and len(tag.as_vec()) == 3) and tag.as_vec()[2] == "read")):
|
or ((tag.as_vec()[0] == 'r' and len(tag.as_vec()) == 3) and tag.as_vec()[2] == "read")):
|
||||||
rtag = tag.as_vec()[1]
|
rtag = tag.as_vec()[1]
|
||||||
if rtag.rstrip("/") not in dvm_config.AVOID_PAID_OUTBOX_RELAY_LIST:
|
if rtag.rstrip("/") not in dvm_config.AVOID_PAID_OUTBOX_RELAY_LIST:
|
||||||
@@ -140,7 +140,10 @@ def send_event_outbox(event: Event, client, dvm_config) -> EventId:
|
|||||||
for index, param in enumerate(tag.as_vec()):
|
for index, param in enumerate(tag.as_vec()):
|
||||||
if index != 0:
|
if index != 0:
|
||||||
if tag.as_vec()[index].rstrip("/") not in dvm_config.AVOID_PAID_OUTBOX_RELAY_LIST:
|
if tag.as_vec()[index].rstrip("/") not in dvm_config.AVOID_PAID_OUTBOX_RELAY_LIST:
|
||||||
relays.append(tag.as_vec()[index])
|
try:
|
||||||
|
relays.append(tag.as_vec()[index])
|
||||||
|
except:
|
||||||
|
print(tag.as_vec()[index] + "couldn't be added")
|
||||||
break
|
break
|
||||||
|
|
||||||
|
|
||||||
@@ -168,10 +171,18 @@ def send_event_outbox(event: Event, client, dvm_config) -> EventId:
|
|||||||
|
|
||||||
for relay in relays:
|
for relay in relays:
|
||||||
opts = RelayOptions().ping(False)
|
opts = RelayOptions().ping(False)
|
||||||
outboxclient.add_relay_with_opts(relay, opts)
|
try:
|
||||||
|
outboxclient.add_relay_with_opts(relay, opts)
|
||||||
|
except:
|
||||||
|
print(relay + "couldn't be added")
|
||||||
|
|
||||||
|
|
||||||
outboxclient.connect()
|
outboxclient.connect()
|
||||||
event_id = outboxclient.send_event(event)
|
try:
|
||||||
|
event_id = outboxclient.send_event(event)
|
||||||
|
except:
|
||||||
|
event_id = send_event(event, client, dvm_config)
|
||||||
|
|
||||||
outboxclient.shutdown()
|
outboxclient.shutdown()
|
||||||
|
|
||||||
return event_id
|
return event_id
|
||||||
|
Reference in New Issue
Block a user