diff options
author | Madeline <46743919+MaddyUnderStars@users.noreply.github.com> | 2022-12-23 12:44:04 +1100 |
---|---|---|
committer | Puyodead1 <puyodead@proton.me> | 2023-03-18 19:23:20 -0400 |
commit | a4961800d7b6b37864b7b7c44893c734ef1b05ae (patch) | |
tree | c633c3de4d901e3ac5e4742220d06874a5702810 /src/api/routes | |
parent | implement PATCH connection (diff) | |
download | server-a4961800d7b6b37864b7b7c44893c734ef1b05ae.tar.xz |
`handleCallback` returns connection if created for `USER_CONNECTIONS_UPDATE`
Diffstat (limited to 'src/api/routes')
-rw-r--r-- | src/api/routes/connections/#connection_name/callback.ts | 15 |
1 files changed, 8 insertions, 7 deletions
diff --git a/src/api/routes/connections/#connection_name/callback.ts b/src/api/routes/connections/#connection_name/callback.ts index 80a5b784..250d4710 100644 --- a/src/api/routes/connections/#connection_name/callback.ts +++ b/src/api/routes/connections/#connection_name/callback.ts @@ -1,11 +1,11 @@ -import { Request, Response, Router } from "express"; +import { route } from "@fosscord/api"; import { ConnectionCallbackSchema, + ConnectionStore, emitEvent, FieldErrors, -} from "../../../../util"; -import { ConnectionStore } from "../../../../util/connections"; -import { route } from "../../../util"; +} from "@fosscord/util"; +import { Request, Response, Router } from "express"; const router = Router(); @@ -36,15 +36,16 @@ router.post( const body = req.body as ConnectionCallbackSchema; const userId = connection.getUserId(body.state); - const emit = await connection.handleCallback(body); + const connectedAccnt = await connection.handleCallback(body); // whether we should emit a connections update event, only used when a connection doesnt already exist - if (emit) + if (connectedAccnt) emitEvent({ event: "USER_CONNECTIONS_UPDATE", - data: {}, + data: connectedAccnt, user_id: userId, }); + res.sendStatus(204); }, ); |