misc updates

This commit is contained in:
May 2024-06-17 14:25:45 -05:00
parent 04a34665f9
commit 8845e9c775
3 changed files with 9 additions and 1 deletions

View file

@ -1,5 +1,6 @@
import {z} from "zod" import {z} from "zod"
import { FileId, FileVisibility } from "./files.js" import { FileId, FileVisibility } from "./files.js"
import { RGBHex } from "./misc.js"
export const StringPassword = z.string().min(8,"password must be at least 8 characters") export const StringPassword = z.string().min(8,"password must be at least 8 characters")
export const Password = export const Password =
@ -46,7 +47,7 @@ export namespace Settings {
barSide: BarSide.default("left") barSide: BarSide.default("left")
}) })
export const Links = z.object({ export const Links = z.object({
color: z.string().toLowerCase().length(6).regex(/^[a-f0-9]+$/,"illegal characters").optional(), color: RGBHex.optional(),
largeImage: z.boolean().default(false) largeImage: z.boolean().default(false)
}) })
export const User = z.object({ export const User = z.object({

View file

@ -0,0 +1,3 @@
import { z } from "zod";
export const RGBHex = z.string().toLowerCase().length(6).regex(/^[a-f0-9]+$/,"illegal characters")

View file

@ -13,6 +13,7 @@ import pkg from "../../../../lib/package.js"
import { type StatusCode } from "hono/utils/http-status" import { type StatusCode } from "hono/utils/http-status"
import { z } from "zod" import { z } from "zod"
import { FileSchemas } from "../../../../lib/schemas/index.js" import { FileSchemas } from "../../../../lib/schemas/index.js"
import config from "../../../../lib/config.js"
const router = new Hono<{ const router = new Hono<{
Variables: { Variables: {
@ -54,6 +55,9 @@ export default function(files: Files) {
if (!ctx.req.raw.body) if (!ctx.req.raw.body)
return resolve(ctx.body("body must be supplied", 400)) return resolve(ctx.body("body must be supplied", 400))
if (config.accounts.requiredForUpload && !acc)
return resolve(ctx.body("instance requires you to be authenticated to upload files", 401))
let file = files.createWriteStream(acc?.id) let file = files.createWriteStream(acc?.id)
file file