From 8685cce273f238375c5ed7beccd620df9aed29d7 Mon Sep 17 00:00:00 2001 From: Believethehype <1097224+believethehype@users.noreply.github.com> Date: Sun, 28 Apr 2024 08:29:25 +0200 Subject: [PATCH] add nip05 to filter, remove broken relay --- ui/noogle/src/components/FilterGeneration.vue | 34 +++++++++++++++++-- ui/noogle/src/store.js | 3 +- 2 files changed, 34 insertions(+), 3 deletions(-) diff --git a/ui/noogle/src/components/FilterGeneration.vue b/ui/noogle/src/components/FilterGeneration.vue index 802429d..a3e80ed 100644 --- a/ui/noogle/src/components/FilterGeneration.vue +++ b/ui/noogle/src/components/FilterGeneration.vue @@ -408,7 +408,7 @@ async function listen() { for (let profile of profiles){ - console.log(profile) + let name = profile === undefined ? "" : profile["profile"]["name"] let picture = profile === undefined ? "../assets/nostr-purple.svg" : profile["profile"]["picture"] @@ -416,6 +416,8 @@ async function listen() { let njumpurl = "https://njump.me/" + PublicKey.parse(profile["author"]).toBech32() let nostrudelurl = "https://nostrudel.ninja/#/n/" + profile["author"] + let isnip05valid = false + /* let p = profiles.find(record => record.author === evt.author.toHex()) let bech32id = evt.id.toBech32() @@ -435,6 +437,7 @@ async function listen() { items.push({ id: profile["author"], + isnip05valid: isnip05valid, event: profile, author: name, authorid: profile["author"], @@ -485,6 +488,30 @@ async function listen() { client.handleNotifications(handle); } +async function isnip05valid(profile){ + let isnip05valid = false + if (profile["profile"]["nip05"] !== undefined && profile["profile"]["nip05"] !== ""){ + try{ + let domain = profile["profile"]["nip05"].split('@')[1] + let user = profile["profile"]["nip05"].split('@')[0] + let checknip05url = "https://" + domain + "/.well-known/nostr.json?name=" + user + //console.log(checknip05url) + let response = await fetch(checknip05url); + let data = await response.json(); + let usernpub = data.names[user] + if (usernpub === profile["author"]){ + isnip05valid = true + } + } + catch (error){ + isnip05valid = false + } + + } + + return isnip05valid + +} async function addAllContentDVMs() { let relevant_dvms = [] @@ -1041,7 +1068,7 @@ const submitHandler = async () => {