From fd8442c6325f0b30d12b7087580d44ebf425891c Mon Sep 17 00:00:00 2001 From: Jon Staab Date: Mon, 2 Jun 2025 16:33:55 -0700 Subject: [PATCH] Remove space blossom detection --- .../components/ContentLinkBlockImage.svelte | 47 +++-------------- src/app/editor/index.ts | 51 ++----------------- src/routes/spaces/[relay]/+layout.svelte | 4 -- 3 files changed, 11 insertions(+), 91 deletions(-) diff --git a/src/app/components/ContentLinkBlockImage.svelte b/src/app/components/ContentLinkBlockImage.svelte index e0154b8c..87db7402 100644 --- a/src/app/components/ContentLinkBlockImage.svelte +++ b/src/app/components/ContentLinkBlockImage.svelte @@ -1,49 +1,14 @@ - + diff --git a/src/app/editor/index.ts b/src/app/editor/index.ts index 387c1ec7..c560a503 100644 --- a/src/app/editor/index.ts +++ b/src/app/editor/index.ts @@ -2,59 +2,18 @@ import {mount} from "svelte" import type {Writable} from "svelte/store" import {get} from "svelte/store" import type {StampedEvent} from "@welshman/util" -import {makeEvent, getTagValues, getListTags, BLOSSOM_AUTH} from "@welshman/util" -import {simpleCache, normalizeUrl, removeNil, now} from "@welshman/lib" +import {getTagValues, getListTags} from "@welshman/util" import {Router} from "@welshman/router" import {signer, profileSearch, userBlossomServers} from "@welshman/app" import {Editor, MentionSuggestion, WelshmanExtension} from "@welshman/editor" import {makeMentionNodeView} from "./MentionNodeView" import ProfileSuggestion from "./ProfileSuggestion.svelte" -export const hasBlossomSupport = simpleCache(async ([url]: [string]) => { - const $signer = signer.get() - const headers: Record = { - "X-Content-Type": "text/plain", - "X-Content-Length": "1", - "X-SHA-256": "73cb3858a687a8494ca3323053016282f3dad39d42cf62ca4e79dda2aac7d9ac", - } - - try { - if ($signer) { - const event = await signer.get().sign( - makeEvent(BLOSSOM_AUTH, { - tags: [ - ["t", "upload"], - ["server", url], - ["expiration", String(now() + 30)], - ], - }), - ) - - headers.Authorization = `Nostr ${btoa(JSON.stringify(event))}` - } - - const res = await fetch(normalizeUrl(url) + "/upload", {method: "head", headers}) - - return res.status === 200 - } catch (e) { - if (!String(e).includes("Failed to fetch")) { - console.error(e) - } - } - - return false -}) - -export const getUploadUrl = async (spaceUrl?: string) => { +export const getUploadUrl = () => { const userUrls = getTagValues("server", getListTags(userBlossomServers.get())) - const allUrls = removeNil([spaceUrl, ...userUrls]) - for (let url of allUrls) { - url = url.replace(/^ws/, "http") - - if (await hasBlossomSupport(url)) { - return url - } + for (const url of userUrls) { + return url.replace(/^ws/, "http") } return "https://cdn.satellite.earth" @@ -98,7 +57,7 @@ export const makeEditor = async ({ submit, sign: signWithAssert, defaultUploadType: "blossom", - defaultUploadUrl: await getUploadUrl(url), + defaultUploadUrl: getUploadUrl(), extensions: { placeholder: { config: { diff --git a/src/routes/spaces/[relay]/+layout.svelte b/src/routes/spaces/[relay]/+layout.svelte index 5c8b07bd..21e97e40 100644 --- a/src/routes/spaces/[relay]/+layout.svelte +++ b/src/routes/spaces/[relay]/+layout.svelte @@ -10,7 +10,6 @@ import SpaceAuthError from "@app/components/SpaceAuthError.svelte" import {pushToast} from "@app/toast" import {pushModal} from "@app/modal" - import {getUploadUrl} from "@app/editor" import {setChecked} from "@app/notifications" import {checkRelayConnection, checkRelayAuth, checkRelayAccess} from "@app/commands" import {decodeRelay, userRoomsByUrl} from "@app/state" @@ -53,9 +52,6 @@ onMount(() => { checkConnection() - // Prime our cache so inputs show up quickly - getUploadUrl(url) - const relays = [url] const since = ago(WEEK) const controller = new AbortController()