mirror of
https://github.com/mollersuite/monofile.git
synced 2024-11-24 14:46:27 -08:00
Ahhhhh im gonna figure this out when i get homeee
This commit is contained in:
parent
dc111da787
commit
e9df285ef7
|
@ -148,54 +148,21 @@ export default function (files: Files) {
|
||||||
)
|
)
|
||||||
|
|
||||||
router.patch(
|
router.patch(
|
||||||
"/dfv",
|
"/:user",
|
||||||
requiresAccount,
|
requiresAccount,
|
||||||
requiresPermissions("manage"),
|
requiresPermissions("manage"),
|
||||||
async (ctx) => {
|
async (ctx) => {
|
||||||
const body = await ctx.req.json()
|
const body = await ctx.req.json() as UserUpdateParameters
|
||||||
const Account = ctx.get("account")! as Accounts.Account
|
const actor = ctx.get("account")! as Accounts.Account
|
||||||
|
const target = ctx.get("target")! as Accounts.Account
|
||||||
|
if (Array.isArray(body))
|
||||||
|
return ServeError(ctx, 400, "invalid body")
|
||||||
|
|
||||||
if (
|
Object.entries(body).filter(e => e[1]).map(([x]) => {
|
||||||
["public", "private", "anonymous"].includes(
|
if (x in validators) {
|
||||||
body.defaultFileVisibility
|
validators[x](actor, target, body as any)
|
||||||
)
|
}
|
||||||
) {
|
})
|
||||||
Account.defaultFileVisibility = body.defaultFileVisibility
|
|
||||||
|
|
||||||
Accounts.save()
|
|
||||||
|
|
||||||
return ctx.text(
|
|
||||||
`dfv has been set to ${Account.defaultFileVisibility}`
|
|
||||||
)
|
|
||||||
} else {
|
|
||||||
return ServeError(ctx, 400, "invalid dfv")
|
|
||||||
}
|
|
||||||
}
|
|
||||||
)
|
|
||||||
|
|
||||||
router.patch(
|
|
||||||
"/dfv",
|
|
||||||
requiresAccount,
|
|
||||||
requiresPermissions("manage"),
|
|
||||||
async (ctx) => {
|
|
||||||
const body = await ctx.req.json()
|
|
||||||
const Account = ctx.get("account")! as Accounts.Account
|
|
||||||
|
|
||||||
if (
|
|
||||||
["public", "private", "anonymous"].includes(
|
|
||||||
body.defaultFileVisibility
|
|
||||||
)
|
|
||||||
) {
|
|
||||||
Account.defaultFileVisibility = body.defaultFileVisibility
|
|
||||||
|
|
||||||
Accounts.save()
|
|
||||||
|
|
||||||
return ctx.text(
|
|
||||||
`dfv has been set to ${Account.defaultFileVisibility}`
|
|
||||||
)
|
|
||||||
} else {
|
|
||||||
return ServeError(ctx, 400, "invalid dfv")
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue