fixes crash on empty response

This commit is contained in:
dbth 2024-12-31 15:13:17 +01:00
parent fbc7361ca5
commit 09873fd990
3 changed files with 29 additions and 24 deletions

View File

@ -640,18 +640,20 @@ class DVM:
#print(reply_event)
# send_event(reply_event, client=self.client, dvm_config=self.dvm_config)
response_status = await send_event_outbox(reply_event, client=self.client, dvm_config=self.dvm_config)
if response_status is not None:
if self.dvm_config.LOGLEVEL.value >= LogLevel.DEBUG.value:
print(bcolors.GREEN + "[" + self.dvm_config.NIP89.NAME + "] " + str(
original_event.kind().as_u16() + 1000) + " Job Response event sent: " + reply_event.as_json() + ". Success: " + str(
response_status.success) + " Failed: " + str(response_status.failed) + " EventID: "
+ response_status.id.to_hex() + " / " + response_status.id.to_bech32() + bcolors.ENDC)
if self.dvm_config.LOGLEVEL.value >= LogLevel.DEBUG.value:
print(bcolors.GREEN + "[" + self.dvm_config.NIP89.NAME + "] " + str(
original_event.kind().as_u16() + 1000) + " Job Response event sent: " + reply_event.as_json() + ". Success: " + str(
response_status.success) + " Failed: " + str(response_status.failed) + " EventID: "
+ response_status.id.to_hex() + " / " + response_status.id.to_bech32() + bcolors.ENDC)
elif self.dvm_config.LOGLEVEL.value >= LogLevel.INFO.value:
print(bcolors.GREEN + "[" + self.dvm_config.NIP89.NAME + "] " + str(
original_event.kind().as_u16() + 1000) + " Job Response event sent. Success: " + str(
response_status.success) + " Failed: " + str(response_status.failed) + " EventID: "
+ response_status.id.to_hex() + " / " + response_status.id.to_bech32() + bcolors.ENDC)
elif self.dvm_config.LOGLEVEL.value >= LogLevel.INFO.value:
print(bcolors.GREEN + "[" + self.dvm_config.NIP89.NAME + "] " + str(
original_event.kind().as_u16() + 1000) + " Job Response event sent. Success: " + str(
response_status.success) + " Failed: " + str(response_status.failed) + " EventID: "
+ response_status.id.to_hex() + " / " + response_status.id.to_bech32() + bcolors.ENDC)
else:
print( bcolors.RED + "No success" + bcolors.ENDC)
async def send_job_status_reaction(original_event, status, is_paid=True, amount=0, client=None,
content=None,
@ -775,17 +777,20 @@ class DVM:
reaction_event = EventBuilder(EventDefinitions.KIND_FEEDBACK, str(content)).tags(reply_tags).sign_with_keys(keys)
# send_event(reaction_event, client=self.client, dvm_config=self.dvm_config)
response_status = await send_event_outbox(reaction_event, client=self.client, dvm_config=self.dvm_config)
if self.dvm_config.LOGLEVEL.value >= LogLevel.DEBUG.value:
print(bcolors.YELLOW + "[" + self.dvm_config.NIP89.NAME + "] Sent Kind " + str(
EventDefinitions.KIND_FEEDBACK.as_u16()) + " Reaction: " + status + " " + reaction_event.as_json() + ". Success: " + str(
response_status.success) + " Failed: " + str(response_status.failed) + " EventID: "
+ response_status.id.to_hex() + " / " + response_status.id.to_bech32() + bcolors.ENDC)
if response_status is not None:
if self.dvm_config.LOGLEVEL.value >= LogLevel.DEBUG.value:
print(bcolors.YELLOW + "[" + self.dvm_config.NIP89.NAME + "] Sent Kind " + str(
EventDefinitions.KIND_FEEDBACK.as_u16()) + " Reaction: " + status + " " + reaction_event.as_json() + ". Success: " + str(
response_status.success) + " Failed: " + str(response_status.failed) + " EventID: "
+ response_status.id.to_hex() + " / " + response_status.id.to_bech32() + bcolors.ENDC)
elif self.dvm_config.LOGLEVEL.value >= LogLevel.INFO.value:
print(bcolors.YELLOW + "[" + self.dvm_config.NIP89.NAME + "] Sent Kind " + str(
EventDefinitions.KIND_FEEDBACK.as_u16()) + " Reaction: " + status + ". Success: " + str(
response_status.success) + " Failed: " + str(response_status.failed) + " EventID: "
+ response_status.id.to_hex() + " / " + response_status.id.to_bech32() + bcolors.ENDC)
elif self.dvm_config.LOGLEVEL.value >= LogLevel.INFO.value:
print(bcolors.YELLOW + "[" + self.dvm_config.NIP89.NAME + "] Sent Kind " + str(
EventDefinitions.KIND_FEEDBACK.as_u16()) + " Reaction: " + status + ". Success: " + str(
response_status.success) + " Failed: " + str(response_status.failed) + " EventID: "
+ response_status.id.to_hex() + " / " + response_status.id.to_bech32() + bcolors.ENDC)
else:
print(bcolors.RED + "No success" + bcolors.ENDC)
return reaction_event.as_json()

View File

@ -57,11 +57,11 @@ AVOID_OUTBOX_RELAY_LIST = ["wss://nos.lol", "wss://nostr.fmt.wiz.biz", "wss://no
"wss://nostr.cro.social", "wss://datagrave.wild-vibes.ts.net/nostr", "wss://nostr01.sharkshake.net",
"wss://relay.nostreggs.io", "wss://nostr.rocks", "wss://groups.0xchat.com",
"wss://bostr.lecturify.net", "wss://dave.st.germa.in/nostr",
"wss://nostr.social", "wss://i.nostr.build",
"wss://nostr.social", "wss://i.nostr.build", "wss://invillage-outvillage.com",
"wss://teemie1-relay.duckdns.org", "wss://newperspectives.duckdns.org",
"wss://nostrs.build", "wss://relay.hllo.live", "wss://relay-pub.deschooling.us",
"wss://nostr.sandwich.farm", "wss://nostr.lol", "wss://nostr.developer.li",
"wss://paid.spore.ws", "ws://relay.damus.io",
"wss://paid.spore.ws", "ws://relay.damus.io", "wss://taipei.scarab", "wss://taipei.scarab.im",
"ws://ofotwjuiv7t6q4azt2fjx3qo7esglmxdeqmh2qvdsdnxw5eqgza24iyd.onion", "wss://r.kojira.io",
"wss://nostr-relay.h3z.jp", "wss://relay.yozora.world",
"wss://nostr.0xtr.dev", "wss://purplepeg.es", "wss://nostr.mutinywallet.com",

View File

@ -1,6 +1,6 @@
from setuptools import setup, find_packages
VERSION = '1.0.6'
VERSION = '1.0.7'
DESCRIPTION = 'A framework to build and run Nostr NIP90 Data Vending Machines'
LONG_DESCRIPTION = ('A framework to build and run Nostr NIP90 Data Vending Machines. See the github repository for more information')