From a60f147156d688696dbb767c0d681d1c01198be3 Mon Sep 17 00:00:00 2001 From: Madeline <46743919+MaddyUnderStars@users.noreply.github.com> Date: Sat, 24 Dec 2022 14:00:54 +1100 Subject: Fix connection update visibilty dying when given boolean --- .../@me/connections/#connection_name/#connection_id/index.ts | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/api/routes/users/@me/connections/#connection_name/#connection_id/index.ts b/src/api/routes/users/@me/connections/#connection_name/#connection_id/index.ts index 84863f6a..9d5f517d 100644 --- a/src/api/routes/users/@me/connections/#connection_name/#connection_id/index.ts +++ b/src/api/routes/users/@me/connections/#connection_name/#connection_id/index.ts @@ -1,5 +1,5 @@ import { route } from "@fosscord/api"; -import { ConnectedAccount, DiscordApiErrors, emitEvent } from "@fosscord/util"; +import { ConnectedAccount, DiscordApiErrors, emitEvent, ConnectionUpdateSchema } from "@fosscord/util"; import { Request, Response, Router } from "express"; const router = Router(); @@ -9,6 +9,7 @@ router.patch( route({ body: "ConnectionUpdateSchema" }), async (req: Request, res: Response) => { const { connection_name, connection_id } = req.params; + const body = req.body as ConnectionUpdateSchema; const connection = await ConnectedAccount.findOne({ where: { @@ -31,7 +32,12 @@ router.patch( if (!connection) return DiscordApiErrors.UNKNOWN_CONNECTION; // TODO: do we need to do anything if the connection is revoked? + + //@ts-ignore For some reason the client sends this as a boolean, even tho docs say its a number? + if (typeof body.visibility === "boolean") body.visibility = body.visibility ? 1 : 0; + connection.assign(req.body); + await ConnectedAccount.update( { user_id: req.user_id, -- cgit 1.4.1