From 96180bb808145fd995c93eafd80c3311fab76b5c Mon Sep 17 00:00:00 2001 From: Mar0xy Date: Sun, 24 Sep 2023 22:50:59 +0200 Subject: [PATCH] add: x-www-form-urlencoded parser --- .../server/api/mastodon/MastodonApiServerService.ts | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/packages/backend/src/server/api/mastodon/MastodonApiServerService.ts b/packages/backend/src/server/api/mastodon/MastodonApiServerService.ts index 7c1a407c5..6c1ba6e53 100644 --- a/packages/backend/src/server/api/mastodon/MastodonApiServerService.ts +++ b/packages/backend/src/server/api/mastodon/MastodonApiServerService.ts @@ -45,6 +45,16 @@ export class MastodonApiServerService { done(); }); + fastify.addContentTypeParser(['application/x-www-form-urlencoded'], { parseAs: 'string' }, function (req, body, done) { + const dataObj = {}; + const parsedData = new URLSearchParams(body as string); + for (var pair of parsedData.entries()) { + //@ts-ignore + dataObj[pair[0]] = pair[1]; + } + done(null, dataObj) + }); + fastify.register(multer.contentParser); fastify.get('/v1/custom_emojis', async (_request, reply) => {