From 8551df92b96ff69f3cda50184cb714ba30f3803d Mon Sep 17 00:00:00 2001 From: Adam Soltys Date: Tue, 3 Mar 2026 16:08:52 -0800 Subject: get rid of /receive route --- src/routes/(app)/invoice/+page.server.ts | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) (limited to 'src/routes/(app)/invoice/+page.server.ts') diff --git a/src/routes/(app)/invoice/+page.server.ts b/src/routes/(app)/invoice/+page.server.ts index 92cfd18d..e3d8125f 100644 --- a/src/routes/(app)/invoice/+page.server.ts +++ b/src/routes/(app)/invoice/+page.server.ts @@ -3,16 +3,20 @@ import type { Invoice } from "$lib/types"; import { auth, post } from "$lib/utils"; import { error, redirect } from "@sveltejs/kit"; -export const load = async ({ cookies, parent }) => { +export const load = async ({ cookies, parent, url }) => { const aid = cookies.get("aid"); let { subject, user } = await parent(); const rates = await getRates(); - if (aid === user.id) redirect(307, `/${user.username}/receive`); + + const type = url.searchParams.get("type") || undefined; + const address_type = url.searchParams.get("address_type") || undefined; let invoice: Invoice = { aid: aid || "", rate: rates[user?.currency || subject?.currency], + ...(type && { type }), + ...(address_type && { address_type }), }; if (!user) user = subject; @@ -26,7 +30,9 @@ export const load = async ({ cookies, parent }) => { const { id } = invoice; + const lnurl = url.searchParams.has("lnurl"); + if (invoice.memoPrompt && !invoice.memo) { redirect(307, `/invoice/${id}/memo`); - } else redirect(307, `/invoice/${id}`); + } else redirect(307, `/invoice/${id}${lnurl ? "?lnurl=true" : ""}`); }; -- cgit v1.2.3