fix: Multi-method handlers, regressed in methodOverride removal

This commit is contained in:
Tom Moor
2022-10-18 23:50:14 -04:00
parent 7a9c75b9f1
commit 98f997387c
4 changed files with 8 additions and 4 deletions

View File

@@ -147,7 +147,7 @@ router.post("attachments.delete", auth(), async (ctx) => {
});
const handleAttachmentsRedirect = async (ctx: ContextWithState) => {
const { id } = (ctx.request.body ?? ctx.request.query) as { id?: string };
const id = ctx.request.body?.id ?? ctx.request.query?.id;
assertUuid(id, "id is required");
const { user } = ctx.state;

View File

@@ -12,7 +12,9 @@ import InviteReminderTask from "@server/queues/tasks/InviteReminderTask";
const router = new Router();
const cronHandler = async (ctx: Context) => {
const { token, limit = 500 } = (ctx.request.body ?? ctx.request.query) as {
const { token, limit = 500 } = (ctx.method === "POST"
? ctx.request.body
: ctx.request.query) as {
token?: string;
limit: number;
};

View File

@@ -70,7 +70,7 @@ router.post(
);
const handleFileOperationsRedirect = async (ctx: ContextWithState) => {
const { id } = (ctx.request.body ?? ctx.request.query) as { id?: string };
const id = ctx.request.body?.id ?? ctx.request.query?.id;
assertUuid(id, "id is required");
const { user } = ctx.state;

View File

@@ -57,7 +57,9 @@ router.post("notificationSettings.delete", auth(), async (ctx) => {
});
const handleUnsubscribe = async (ctx: ContextWithState) => {
const { id, token } = (ctx.request.body ?? ctx.request.query) as {
const { id, token } = (ctx.method === "POST"
? ctx.request.body
: ctx.request.query) as {
id?: string;
token?: string;
};