From d707d2c696184b5ad90132cb0a4b5673d15d6644 Mon Sep 17 00:00:00 2001 From: Adam Soltys Date: Wed, 25 Nov 2026 15:19:16 -0700 Subject: Fund page: show the discontinued notice only when someone acts on a fund The history is shown without the notice. Manage, and old sweep, authorize and access links, bring up the notice instead of doing anything; the sweep link no longer creates an account for signed-out visitors first. Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_01VMan6W9CsdxmhFrfaKNVHU --- src/locales/en.json | 2 +- src/routes/(app)/fund/[id]/+page.svelte | 37 ++++++++++--- src/routes/(app)/fund/[id]/access/+page.server.ts | 10 ++-- .../[id]/authorize/[...amount]/+page.server.ts | 41 +++------------ .../fund/[id]/sweep/[...amount]/+page.server.ts | 61 +++------------------- 5 files changed, 49 insertions(+), 102 deletions(-) (limited to 'src') diff --git a/src/locales/en.json b/src/locales/en.json index 216403b5..eeaea09f 100644 --- a/src/locales/en.json +++ b/src/locales/en.json @@ -7,7 +7,7 @@ "withdrawAccess": "Withdraw access", "username": "Username", "returnToFund": "Back to fund", - "discontinued": "Funds have been discontinued. This fund's history is shown below for reference, but it can no longer receive or send payments.", + "discontinued": "Funds have been discontinued. This fund can no longer receive or send payments, but its history is still shown here for reference.", "notFound": "Funds have been discontinued, and this fund could not be found." }, "notes": { diff --git a/src/routes/(app)/fund/[id]/+page.svelte b/src/routes/(app)/fund/[id]/+page.svelte index 087c8c95..289d1859 100644 --- a/src/routes/(app)/fund/[id]/+page.svelte +++ b/src/routes/(app)/fund/[id]/+page.svelte @@ -23,6 +23,11 @@ let amountFiat = $derived(parseFloat(((amount * rate) / sats).toFixed(2))); $effect(() => ($loginRedirect = $page.url.pathname)); + // Funds are discontinued: the notice only appears once someone tries to + // act on the fund (Manage, or an old withdraw/authorize link redirecting + // here with ?discontinued). + let discontinued = $state($page.url.searchParams.has("discontinued")); + let show = $state(); let toggle = () => (show = !show); let href = $derived(encodeURIComponent($page.url.href)); @@ -37,12 +42,14 @@
-
- - - {notFound ? $t("funds.notFound") : $t("funds.discontinued")} - -
+ {#if notFound || discontinued} +
+ + + {notFound ? $t("funds.notFound") : $t("funds.discontinued")} + +
+ {/if} {#if !notFound} {#if show}
@@ -75,6 +82,24 @@
{$t("funds.anyone")}
{/if}
+ + {#if (user && !managers.length) || managers.some((m) => m.id === user?.id)} + + {/if} +
+ {/if} diff --git a/src/routes/(app)/fund/[id]/access/+page.server.ts b/src/routes/(app)/fund/[id]/access/+page.server.ts index 36191643..d409061d 100644 --- a/src/routes/(app)/fund/[id]/access/+page.server.ts +++ b/src/routes/(app)/fund/[id]/access/+page.server.ts @@ -1,9 +1,9 @@ -import { auth, fd, get, post } from "$lib/utils"; -import { fail } from "@sveltejs/kit"; +import { auth, fd, post } from "$lib/utils"; +import { fail, redirect } from "@sveltejs/kit"; -export const load = async ({ params: { id } }) => { - const managers = await get(`/fund/${id}/managers`); - return { managers, id }; +// Funds are discontinued; managers can no longer be changed. +export const load = ({ params: { id } }) => { + redirect(307, `/fund/${id}?discontinued`); }; export const actions = { diff --git a/src/routes/(app)/fund/[id]/authorize/[...amount]/+page.server.ts b/src/routes/(app)/fund/[id]/authorize/[...amount]/+page.server.ts index e5683ae6..82faa387 100644 --- a/src/routes/(app)/fund/[id]/authorize/[...amount]/+page.server.ts +++ b/src/routes/(app)/fund/[id]/authorize/[...amount]/+page.server.ts @@ -1,36 +1,7 @@ -import getRates from "$lib/rates"; -import { auth, get, post, sats } from "$lib/utils"; -import { error, redirect } from "@sveltejs/kit"; +import { redirect } from "@sveltejs/kit"; -export async function load({ cookies, params, parent }) { - const { user } = await parent(); - const { id } = params; - let [amount, currency] = params.amount.split("/"); - let fiat; - - if (!currency) currency = user?.currency; - if (currency) currency = currency.toUpperCase(); - - const rates = await getRates(); - const rate = rates[currency || "USD"]; - if (currency && !rate) error(500, "Invalid currency symbol"); - - if (!amount) { - const balance = await get(`/fund/${id}`); - amount = balance.amount; - } else if (currency) { - fiat = amount; - amount = Math.round((fiat * sats) / rate); - } - - if (!amount) redirect(307, `/fund/${id}`); - - try { - await post("/authorize", { amount, currency, fiat, id }, auth(cookies)); - } catch (e) { - console.log("caught", e); - redirect(307, `/fund/${id}`); - } - - return { amount, currency, id, rate, rates }; -} +// Funds are discontinued; old withdraw/authorize links land on the fund page +// with the notice instead. +export const load = ({ params: { id } }) => { + redirect(307, `/fund/${id}?discontinued`); +}; diff --git a/src/routes/(app)/fund/[id]/sweep/[...amount]/+page.server.ts b/src/routes/(app)/fund/[id]/sweep/[...amount]/+page.server.ts index 8cc463c2..82faa387 100644 --- a/src/routes/(app)/fund/[id]/sweep/[...amount]/+page.server.ts +++ b/src/routes/(app)/fund/[id]/sweep/[...amount]/+page.server.ts @@ -1,56 +1,7 @@ -import { randomName, randomPassword } from "$lib/random"; -import getRates from "$lib/rates"; -import { auth, get, post, register, sats } from "$lib/utils"; -import { error, redirect } from "@sveltejs/kit"; -import { env } from "$env/dynamic/private"; +import { redirect } from "@sveltejs/kit"; -export async function load({ cookies, request, params, parent }) { - let { user } = await parent(); - const { id } = params; - let [amount, currency] = params.amount.split("/"); - - if (!currency) currency = user?.currency; - if (currency) currency = currency.toUpperCase(); - const rates = await getRates(); - const rate = rates[currency || "USD"]; - if (currency && !rate) error(500, "Invalid currency symbol"); - - if (!amount) { - const balance = await get(`/fund/${id}`); - amount = balance.authorization || balance.amount; - } else if (currency) { - amount = Math.round((amount * sats) / rate); - } - - const username = randomName() + Math.floor(Math.random() * 99) + 1; - const password = randomPassword(); - - if (!amount) redirect(307, `/fund/${id}`); - if (!user) { - const ip = request.headers.get("cf-connecting-ip"); - - user = { - username, - password, - fresh: true, - }; - - let redirectUrl = `/fund/${id}/sweep`; - if (params.amount && !params.currency) redirectUrl += `/${params.amount}`; - if (params.currency) redirectUrl += `/${params.amount}/params.currency}`; - - const extraHeaders: Record = {}; - if (env.INTERNAL_API_KEY) - extraHeaders["x-api-key"] = env.INTERNAL_API_KEY; - - await register(user, ip, cookies, redirectUrl, undefined, extraHeaders); - } - - try { - ({ amount } = await post("/take", { amount, id }, auth(cookies))); - } catch (e) { - redirect(307, `/fund/${id}`); - } - - return { amount, currency, id, rate, rates, password }; -} +// Funds are discontinued; old withdraw/authorize links land on the fund page +// with the notice instead. +export const load = ({ params: { id } }) => { + redirect(307, `/fund/${id}?discontinued`); +}; -- cgit v1.2.3