diff options
author | Madeline <46743919+MaddyUnderStars@users.noreply.github.com> | 2022-12-24 14:00:54 +1100 |
---|---|---|
committer | Puyodead1 <puyodead@proton.me> | 2023-03-18 19:27:40 -0400 |
commit | a60f147156d688696dbb767c0d681d1c01198be3 (patch) | |
tree | 4b356d4549ff8f01331e9d736d13491b23f05aeb /src | |
parent | Update todo in access-token route (diff) | |
download | server-a60f147156d688696dbb767c0d681d1c01198be3.tar.xz |
Fix connection update visibilty dying when given boolean
Diffstat (limited to 'src')
-rw-r--r-- | src/api/routes/users/@me/connections/#connection_name/#connection_id/index.ts | 8 |
1 files changed, 7 insertions, 1 deletions
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, |