mirror of
https://github.com/mollersuite/monofile.git
synced 2024-11-21 21:36:26 -08:00
refactor: 👽 Remove v0 CSS API and migrate client to v1 CSS API
This commit is contained in:
parent
756077148a
commit
687e083ca2
|
@ -19,7 +19,7 @@
|
|||
|
||||
<link
|
||||
rel="stylesheet"
|
||||
href="/auth/customCSS"
|
||||
href="/api/v1/account/customization/css"
|
||||
>
|
||||
|
||||
<link
|
||||
|
|
|
@ -17,7 +17,7 @@
|
|||
|
||||
<link
|
||||
rel="stylesheet"
|
||||
href="/auth/customCSS"
|
||||
href="/api/v1/account/customization/css"
|
||||
>
|
||||
|
||||
<meta
|
||||
|
|
|
@ -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"
|
||||
|
|
|
@ -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
|
||||
}
|
||||
|
|
|
@ -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) {
|
|||
})
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue