summary refs log tree commit diff
path: root/api/src/util/handlers
diff options
context:
space:
mode:
authorTheArcaneBrony <myrainbowdash949@gmail.com>2022-08-15 11:13:21 +0200
committerTheArcaneBrony <myrainbowdash949@gmail.com>2022-08-15 11:13:21 +0200
commit1a94fb1208bf0e4c669cad16aff5f57dc0bf7a3c (patch)
tree1035116ddbaacc5fcc5ae250a6592eb88f78f75c /api/src/util/handlers
parentDo the funny thing (make user->invite cascade delet) (diff)
parentchange dev panel path, we missed this one... (diff)
downloadserver-1a94fb1208bf0e4c669cad16aff5f57dc0bf7a3c.tar.xz
Merge branch 'dev/restructure' into staging
Diffstat (limited to '')
-rw-r--r--src/api/util/handlers/Instance.ts (renamed from api/src/util/handlers/Instance.ts)0
-rw-r--r--src/api/util/handlers/Message.ts (renamed from api/src/util/handlers/Message.ts)3
-rw-r--r--src/api/util/handlers/Voice.ts (renamed from api/src/util/handlers/Voice.ts)0
-rw-r--r--src/api/util/handlers/route.ts (renamed from api/src/util/handlers/route.ts)7
4 files changed, 8 insertions, 2 deletions
diff --git a/api/src/util/handlers/Instance.ts b/src/api/util/handlers/Instance.ts

index 7c337270..7c337270 100644 --- a/api/src/util/handlers/Instance.ts +++ b/src/api/util/handlers/Instance.ts
diff --git a/api/src/util/handlers/Message.ts b/src/api/util/handlers/Message.ts
index 0f584c56..ff5ece75 100644 --- a/api/src/util/handlers/Message.ts +++ b/src/api/util/handlers/Message.ts
@@ -21,12 +21,13 @@ import { Webhook, Attachment, Config, + MessageCreateSchema, } from "@fosscord/util"; import { HTTPError } from "@fosscord/util"; import fetch from "node-fetch"; import cheerio from "cheerio"; -import { MessageCreateSchema } from "../../routes/channels/#channel_id/messages"; import { OrmUtils } from "@fosscord/util"; + const allow_empty = false; // TODO: check webhook, application, system author, stickers // TODO: embed gifs/videos/images diff --git a/api/src/util/handlers/Voice.ts b/src/api/util/handlers/Voice.ts
index 4d60eb91..4d60eb91 100644 --- a/api/src/util/handlers/Voice.ts +++ b/src/api/util/handlers/Voice.ts
diff --git a/api/src/util/handlers/route.ts b/src/api/util/handlers/route.ts
index eaf7dc91..71e14955 100644 --- a/api/src/util/handlers/route.ts +++ b/src/api/util/handlers/route.ts
@@ -19,7 +19,7 @@ import Ajv from "ajv"; import { AnyValidateFunction } from "ajv/dist/core"; import addFormats from "ajv-formats"; -const SchemaPath = path.join(__dirname, "..", "..", "..", "assets", "schemas.json"); +const SchemaPath = path.join(__dirname, "..", "..", "..","..", "assets", "schemas.json"); const schemas = JSON.parse(fs.readFileSync(SchemaPath, { encoding: "utf8" })); export const ajv = new Ajv({ @@ -117,6 +117,11 @@ export function route(opts: RouteOptions) { const valid = validate(normalizeBody(req.body)); if (!valid) { const fields: Record<string, { code?: string; message: string }> = {}; + if(process.env.LOG_INVALID_BODY) { + console.log(`Got invalid request: ${req.method} ${req.originalUrl}`) + console.log(req.body) + validate.errors?.forEach(x => console.log(x.params)) + } validate.errors?.forEach((x) => (fields[x.instancePath.slice(1)] = { code: x.keyword, message: x.message || "" })); throw FieldErrors(fields); }