mirror of
https://github.com/mollersuite/monofile.git
synced 2024-11-24 06:36: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(
|
||||
"/dfv",
|
||||
"/:user",
|
||||
requiresAccount,
|
||||
requiresPermissions("manage"),
|
||||
async (ctx) => {
|
||||
const body = await ctx.req.json()
|
||||
const Account = ctx.get("account")! as Accounts.Account
|
||||
const body = await ctx.req.json() as UserUpdateParameters
|
||||
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 (
|
||||
["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")
|
||||
}
|
||||
}
|
||||
)
|
||||
|
||||
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")
|
||||
}
|
||||
Object.entries(body).filter(e => e[1]).map(([x]) => {
|
||||
if (x in validators) {
|
||||
validators[x](actor, target, body as any)
|
||||
}
|
||||
})
|
||||
}
|
||||
)
|
||||
|
||||
|
|
Loading…
Reference in a new issue