refactor: 👽 Remove v0 CSS API and migrate client to v1 CSS API

This commit is contained in:
Jack W. 2024-03-07 21:20:05 -05:00
parent 756077148a
commit 687e083ca2
No known key found for this signature in database
5 changed files with 19 additions and 41 deletions

View file

@ -19,7 +19,7 @@
<link
rel="stylesheet"
href="/auth/customCSS"
href="/api/v1/account/customization/css"
>
<link

View file

@ -17,7 +17,7 @@
<link
rel="stylesheet"
href="/auth/customCSS"
href="/api/v1/account/customization/css"
>
<meta

View file

@ -15,7 +15,7 @@
href="/static/assets/icons/icon_temp.svg"
/>
<link rel="stylesheet" href="/auth/customCSS" />
<link rel="stylesheet" href="/api/v1/account/customization/css" />
<meta
name="viewport"

View file

@ -164,32 +164,6 @@ export default function (files: Files) {
}
)
authRoutes.post(
"/customcss",
requiresAccount,
requiresPermissions("customize"),
// Used body-parser
async (ctx) => {
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
}

View file

@ -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)
})
}
})