From 8d7f03b0bcf4491cc7417887a99b2a88ab1e9922 Mon Sep 17 00:00:00 2001 From: dskvr Date: Thu, 25 Jul 2024 11:17:54 +0200 Subject: [PATCH] because blowater --- .../relays/blocks/RelaysResultTable.vue | 2 +- src/components/relays/jobs/CheckNip11.vue | 30 ++++++++++++------- .../relays/jobs/RelayOperatorJob.vue | 4 ++- 3 files changed, 23 insertions(+), 13 deletions(-) diff --git a/src/components/relays/blocks/RelaysResultTable.vue b/src/components/relays/blocks/RelaysResultTable.vue index 4cbc9c3a..f181bf97 100644 --- a/src/components/relays/blocks/RelaysResultTable.vue +++ b/src/components/relays/blocks/RelaysResultTable.vue @@ -177,7 +177,7 @@ diff --git a/src/components/relays/jobs/CheckNip11.vue b/src/components/relays/jobs/CheckNip11.vue index a77ed434..7c7b0e66 100644 --- a/src/components/relays/jobs/CheckNip11.vue +++ b/src/components/relays/jobs/CheckNip11.vue @@ -55,18 +55,26 @@ const localMethods = { result.pubkeyValid = false - if(result.info.pubkey.startsWith('npub')) { - result.pubkeyError = "pubkey is in npub format, should be hex" - return result - } - if(!result.info.pubkey.match(/[0-9A-Fa-f]{6}/g)) { - result.pubkeyError = "pubkey is not hex" - return result + const pubkeyIsString = result?.info?.pubkey && typeof result.info.pubkey === 'string' + + if(pubkeyIsString) { + if(result.info.pubkey.startsWith('npub')) { + result.pubkeyError = "pubkey is in npub format, should be hex" + return result + } + if(!result.info.pubkey?.match(/[0-9A-Fa-f]{6}/g)) { + result.pubkeyError = "pubkey is not hex" + return result + } + + const pubkey = Uint8Array.from(Buffer.from(result.info.pubkey, 'hex')); + if(pubkey.length !== 32){ + result.pubkeyError = 'pubkey is expected to be 32' + return result + } } - - const pubkey = Uint8Array.from(Buffer.from(result.info.pubkey, 'hex')); - if(pubkey.length !== 32){ - result.pubkeyError = 'pubkey is expected to be 32' + else { + result.pubkeyError = 'pubkey is not a string' return result } diff --git a/src/components/relays/jobs/RelayOperatorJob.vue b/src/components/relays/jobs/RelayOperatorJob.vue index 028e1e30..91286d04 100644 --- a/src/components/relays/jobs/RelayOperatorJob.vue +++ b/src/components/relays/jobs/RelayOperatorJob.vue @@ -27,6 +27,9 @@ const localMethods = { if( !this.isExpired(this.slug, 1000) && !force ) return + if( !this.result?.info?.pubkey || typeof this.result.info.pubkey !== 'string' ) + return + this.queueJob( this.slug, () => { @@ -36,7 +39,6 @@ const localMethods = { .on('open', relay => { relay.subscribe(`${subid}-0`, { limit:1, kinds:[0], authors:[this.result.info.pubkey] }) relay.subscribe(`${subid}-1`, { limit:10, kinds:[1], authors:[this.result.info.pubkey] }) - // relay.subscribe(`${subid}-7`, { limit:10, kinds:[7], authors:[this.result.info.pubkey] }) }) .on('event', (relay, sub_id, event) => { if(subid === `${subid}-0`){