summary refs log tree commit diff
diff options
context:
space:
mode:
authorxnacly <matteogropp@gmail.com>2021-03-28 19:12:06 +0200
committerxnacly <matteogropp@gmail.com>2021-03-28 19:12:06 +0200
commit9050415611f883288f1d1e2b8a0e579c9a52a2ef (patch)
treee480c79bba82784594d3e85dea79da58e3723bcc
parent:arrow_up: update fosscord-server-util (diff)
downloadserver-9050415611f883288f1d1e2b8a0e579c9a52a2ef.tar.xz
added GET [#12]
-rw-r--r--src/routes/api/v8/channels/#channel_id/invites.ts19
1 files changed, 19 insertions, 0 deletions
diff --git a/src/routes/api/v8/channels/#channel_id/invites.ts b/src/routes/api/v8/channels/#channel_id/invites.ts

index 0e09c00c..4c21e7d4 100644 --- a/src/routes/api/v8/channels/#channel_id/invites.ts +++ b/src/routes/api/v8/channels/#channel_id/invites.ts
@@ -45,4 +45,23 @@ router.post("/", check(InviteCreateSchema), async (req: Request, res: Response) res.status(201).send(invite); }); +router.get("/", async (req: Request, res: Response) => { + const usID = req.user_id; + const chID = BigInt(req.params.channel_id); + const channel = await ChannelModel.findOne({ id: chID }).exec(); + + if (!channel || !channel.guild_id) { + throw new HTTPError("This channel doesn't exist", 404); + } + const { guild_id: guID } = channel; + const permission = await getPermission(usID, guID); + + if (!permission.has("MANAGE_CHANNELS")) { + throw new HTTPError("You aren't authorised to access this endpoint", 401); + } + + const invites = await InviteModel.find({ guild_id: guID }).exec(); + res.status(200).send(invites); +}); + export default router;