diff --git a/src/agent/pool.ts b/src/agent/pool.ts index 678d5ffe..ada35b0f 100644 --- a/src/agent/pool.ts +++ b/src/agent/pool.ts @@ -62,10 +62,6 @@ const Meta = { stats.subsCount += 1 stats.activeSubsCount += 1 stats.lastRequest = Date.now() - - if (stats.activeSubsCount > 10) { - warn(`Relay ${url} has ${stats.activeSubsCount} active subscriptions`) - } }) }, onSubscriptionEnd(urls) { diff --git a/src/agent/sync.ts b/src/agent/sync.ts index 1a762cb0..4e14d666 100644 --- a/src/agent/sync.ts +++ b/src/agent/sync.ts @@ -1,17 +1,7 @@ import {partition, is, uniq, reject, nth, objOf, pick, identity} from "ramda" import {nip05} from "nostr-tools" import {noop, ensurePlural, chunk} from "hurdak/lib/hurdak" -import { - hexToBech32, - tryFunc, - bech32ToHex, - tryFetch, - now, - sleep, - tryJson, - timedelta, - hash, -} from "src/util/misc" +import {now, sleep, tryJson, timedelta, hash} from "src/util/misc" import {Tags, roomAttrs, isRelay, isShareableRelay, normalizeRelayUrl} from "src/util/nostr" import {topics, people, userEvents, relays, rooms, routes} from "src/agent/db" import {uniqByUrl} from "src/agent/relays" @@ -80,37 +70,6 @@ const verifyNip05 = (pubkey, alias) => } }, noop) -const verifyZapper = async (pubkey, address) => { - let url - - // Try to parse it as a lud06 LNURL or as a lud16 address - if (address.startsWith("lnurl1")) { - url = tryFunc(() => bech32ToHex(address)) - } else if (address.includes("@")) { - const [name, domain] = address.split("@") - - if (domain && name) { - url = `https://${domain}/.well-known/lnurlp/${name}` - } - } - - if (!url) { - return - } - - const res = await tryFetch(() => fetch(url)) - const zapper = await tryJson(() => res?.json()) - const lnurl = hexToBech32("lnurl", url) - - if (zapper?.allowsNostr && zapper?.nostrPubkey) { - updatePerson(pubkey, { - lnurl, - // Trim zapper so we don't have so much metadata filling up memory - zapper: pick(["callback", "maxSendable", "minSendable", "nostrPubkey"], zapper), - }) - } -} - addHandler(0, e => { tryJson(() => { const kind0 = JSON.parse(e.content) @@ -125,12 +84,6 @@ addHandler(0, e => { verifyNip05(e.pubkey, kind0.nip05) } - const address = kind0.lud16 || kind0.lud06 - - if (address) { - verifyZapper(e.pubkey, address.toLowerCase()) - } - updatePerson(e.pubkey, { kind0: {...person?.kind0, ...kind0}, kind0_updated_at: e.created_at, diff --git a/src/agent/user.ts b/src/agent/user.ts index ed33938a..f6ca82c4 100644 --- a/src/agent/user.ts +++ b/src/agent/user.ts @@ -12,7 +12,6 @@ const profile = synced("agent/user/profile", { pubkey: null, kind0: null, lnurl: null, - zapper: null, rooms_joined: [], last_checked: {}, relays: pool.defaultRelays, diff --git a/src/app/shared/NoteActions.svelte b/src/app/shared/NoteActions.svelte index 0ea87d2a..90275464 100644 --- a/src/app/shared/NoteActions.svelte +++ b/src/app/shared/NoteActions.svelte @@ -4,7 +4,7 @@ import {tweened} from "svelte/motion" import {find, reject, identity, propEq, pathEq, sum, pluck, sortBy} from "ramda" import {stringToHue, formatSats, hsl} from "src/util/misc" - import {displayRelay, isLike, processZaps} from "src/util/nostr" + import {displayRelay, isLike} from "src/util/nostr" import {quantify, first} from "hurdak/lib/hurdak" import {modal} from "src/partials/state" import Popover from "src/partials/Popover.svelte" @@ -14,7 +14,7 @@ import CopyValue from "src/partials/CopyValue.svelte" import PersonBadge from "src/app/shared/PersonBadge.svelte" import RelayCard from "src/app/shared/RelayCard.svelte" - import {ENABLE_ZAPS, keys} from "src/system" + import {ENABLE_ZAPS, keys, nip57} from "src/system" import {getEventPublishRelays} from "src/agent/relays" import {getPersonWithFallback} from "src/agent/db" import pool from "src/agent/pool" @@ -29,6 +29,7 @@ export let setFeedRelay const {canSign} = keys + const zapper = nip57.zappers.get(note.pubkey) const bech32Note = nip19.noteEncode(note.id) const nevent = nip19.neventEncode({id: note.id, relays: [note.seen_on]}) const interpolate = (a, b) => t => a + Math.round((b - a) * t) @@ -70,12 +71,14 @@ $: allLikes = like ? likes.filter(n => n.id !== like?.id).concat(like) : likes $: $likesCount = allLikes.length - $: zaps = processZaps(note.zaps, $author) + $: zaps = nip57.processZaps(note.zaps, note.pubkey) $: zap = zap || find(pathEq(["request", "pubkey"], user.getPubkey()), zaps) - $: allZaps = zap ? zaps.filter(n => n.id !== zap?.id).concat(processZaps([zap], $author)) : zaps + $: allZaps = zap + ? zaps.filter(n => n.id !== zap?.id).concat(nip57.processZaps([zap], note.pubkey)) + : zaps $: $zapsTotal = sum(pluck("invoiceAmount", allZaps)) / 1000 - $: canZap = $author?.zapper && $author?.pubkey !== user.getPubkey() + $: canZap = zapper && $author?.pubkey !== user.getPubkey() $: $repliesCount = note.replies.length $: { @@ -131,8 +134,7 @@ {#if ENABLE_ZAPS}