summary refs log tree commit diff
path: root/api/src/routes/invites/index.ts
diff options
context:
space:
mode:
authorFlam3rboy <34555296+Flam3rboy@users.noreply.github.com>2021-09-20 17:38:16 +0200
committerFlam3rboy <34555296+Flam3rboy@users.noreply.github.com>2021-09-20 17:38:16 +0200
commit269bbdfeae9672e17f0dbd02172e925fc16eb904 (patch)
tree513c0c125a5d917487822f4d64bce9d2eb3e6429 /api/src/routes/invites/index.ts
parent:arrow_up: update test client (diff)
downloadserver-269bbdfeae9672e17f0dbd02172e925fc16eb904.tar.xz
:sparkles: accept invite page
Diffstat (limited to '')
-rw-r--r--api/src/routes/invites/index.ts9
1 files changed, 2 insertions, 7 deletions
diff --git a/api/src/routes/invites/index.ts b/api/src/routes/invites/index.ts

index ae8a5944..0fcf7c86 100644 --- a/api/src/routes/invites/index.ts +++ b/api/src/routes/invites/index.ts
@@ -15,14 +15,9 @@ router.get("/:code", route({}), async (req: Request, res: Response) => { router.post("/:code", route({}), async (req: Request, res: Response) => { const { code } = req.params; + const invite = await Invite.joinGuild(req.user_id, code); - const invite = await Invite.findOneOrFail({ code }); - if (invite.uses++ >= invite.max_uses) await Invite.delete({ code }); - else await invite.save(); - - await Member.addToGuild(req.user_id, invite.guild_id); - - res.status(200).send(invite); + res.json(invite); }); // * cant use permission of route() function because path doesn't have guild_id/channel_id