diff --git a/src/download.html b/src/download.html index 806c9a8..80a2093 100644 --- a/src/download.html +++ b/src/download.html @@ -19,7 +19,7 @@ - + { - const body = await ctx.req.json() - let acc = ctx.get("account") as Accounts.Account - - if (typeof body.fileId != "string") body.fileId = undefined - - if ( - !body.fileId || - (body.fileId.match(id_check_regex) == body.fileId && - body.fileId.length <= config.maxUploadIdLength) - ) { - acc.customCSS = body.fileId || undefined - if (!body.fileId) delete acc.customCSS - Accounts.save() - return ctx.text(`custom css saved`) - } else { - return ctx.text("invalid fileid", 400) - } - } - ) - authRoutes.post( "/embedcolor", requiresAccount, @@ -626,10 +600,5 @@ export default function (files: Files) { } ) - authRoutes.get("/customCSS", async (ctx) => { - let acc = ctx.get("account") - if (acc?.customCSS) return ctx.redirect(`/file/${acc.customCSS}`) - else return ctx.text("") - }) return authRoutes } diff --git a/src/svelte/elem/prompts/account.js b/src/svelte/elem/prompts/account.js index 27e5f31..b9c1b18 100644 --- a/src/svelte/elem/prompts/account.js +++ b/src/svelte/elem/prompts/account.js @@ -225,16 +225,25 @@ export function customcss(optPicker) { } ]).then((exp) => { if (exp && exp.selected) { - fetch(`/auth/customcss`,{method:"POST", body:JSON.stringify({ - fileId:exp.fileid - })}).then((response) => { - + fetch(`/api/v1/account/customization/css`, { + method: "PUT", + body: JSON.stringify({ + fileId: exp.fileid, + }), + }).then((response) => { if (response.status != 200) { - optPicker.picker(`${response.status} ${response.headers.get("x-backup-status-message") || response.statusText || ""}`,[]) + optPicker.picker( + `${response.status} ${ + response.headers.get("x-backup-status-message") || + response.statusText || + "" + }`, + [] + ) } fetchAccountData() - refreshNeeded.set(true); + refreshNeeded.set(true) }) } }) @@ -300,4 +309,4 @@ export function embedSize(optPicker) { }) } }) -} \ No newline at end of file +}