From 4b9f36d344ec37eeb788ebb4f4c7e9e4d5c2e7a2 Mon Sep 17 00:00:00 2001 From: Flam3rboy <34555296+Flam3rboy@users.noreply.github.com> Date: Wed, 3 Mar 2021 21:14:14 +0100 Subject: [PATCH] :construction: messages route --- .../api/v8/channels/#CHANNELID/messages.ts | 4 --- .../{#CHANNELID => #channel_id}/followers.ts | 0 .../{#CHANNELID => #channel_id}/index.ts | 0 .../{#CHANNELID => #channel_id}/invites.ts | 2 +- .../api/v8/channels/#channel_id/messages.ts | 27 +++++++++++++++++++ .../permissions.ts | 0 .../{#CHANNELID => #channel_id}/pins.ts | 0 .../{#CHANNELID => #channel_id}/recipients.ts | 0 .../{#CHANNELID => #channel_id}/typing.ts | 0 .../{#CHANNELID => #channel_id}/webhooks.ts | 0 10 files changed, 28 insertions(+), 5 deletions(-) delete mode 100644 src/routes/api/v8/channels/#CHANNELID/messages.ts rename src/routes/api/v8/channels/{#CHANNELID => #channel_id}/followers.ts (100%) rename src/routes/api/v8/channels/{#CHANNELID => #channel_id}/index.ts (100%) rename src/routes/api/v8/channels/{#CHANNELID => #channel_id}/invites.ts (96%) create mode 100644 src/routes/api/v8/channels/#channel_id/messages.ts rename src/routes/api/v8/channels/{#CHANNELID => #channel_id}/permissions.ts (100%) rename src/routes/api/v8/channels/{#CHANNELID => #channel_id}/pins.ts (100%) rename src/routes/api/v8/channels/{#CHANNELID => #channel_id}/recipients.ts (100%) rename src/routes/api/v8/channels/{#CHANNELID => #channel_id}/typing.ts (100%) rename src/routes/api/v8/channels/{#CHANNELID => #channel_id}/webhooks.ts (100%) diff --git a/src/routes/api/v8/channels/#CHANNELID/messages.ts b/src/routes/api/v8/channels/#CHANNELID/messages.ts deleted file mode 100644 index 9a4e81fa..00000000 --- a/src/routes/api/v8/channels/#CHANNELID/messages.ts +++ /dev/null @@ -1,4 +0,0 @@ -import { Router } from "express"; -const router: Router = Router(); - -export default router; diff --git a/src/routes/api/v8/channels/#CHANNELID/followers.ts b/src/routes/api/v8/channels/#channel_id/followers.ts similarity index 100% rename from src/routes/api/v8/channels/#CHANNELID/followers.ts rename to src/routes/api/v8/channels/#channel_id/followers.ts diff --git a/src/routes/api/v8/channels/#CHANNELID/index.ts b/src/routes/api/v8/channels/#channel_id/index.ts similarity index 100% rename from src/routes/api/v8/channels/#CHANNELID/index.ts rename to src/routes/api/v8/channels/#channel_id/index.ts diff --git a/src/routes/api/v8/channels/#CHANNELID/invites.ts b/src/routes/api/v8/channels/#channel_id/invites.ts similarity index 96% rename from src/routes/api/v8/channels/#CHANNELID/invites.ts rename to src/routes/api/v8/channels/#channel_id/invites.ts index ee71d1ee..2bf8664f 100644 --- a/src/routes/api/v8/channels/#CHANNELID/invites.ts +++ b/src/routes/api/v8/channels/#channel_id/invites.ts @@ -13,7 +13,7 @@ const router: Router = Router(); router.post("/", check(InviteCreateSchema), async (req: Request, res: Response) => { const usID = req.userid; - const chID = BigInt(req.params.channelid); + const chID = BigInt(req.params.channel_id); const channel = await ChannelModel.findOne({ id: chID }).exec(); if (!channel || !channel.guild_id) { diff --git a/src/routes/api/v8/channels/#channel_id/messages.ts b/src/routes/api/v8/channels/#channel_id/messages.ts new file mode 100644 index 00000000..0826cf94 --- /dev/null +++ b/src/routes/api/v8/channels/#channel_id/messages.ts @@ -0,0 +1,27 @@ +import { Router } from "express"; +import { ChannelModel, ChannelType, getPermission, MessageModel } from "fosscord-server-util"; +import { HTTPError } from "lambert-server"; +const router: Router = Router(); + +export default router; + +router.get("/", async (req, res) => { + const channel_id = BigInt(req.params.channel_id); + const channel = await ChannelModel.findOne( + { id: channel_id }, + { guild_id: true, type: true, permission_overwrites: true } + ).exec(); + if (!channel) throw new HTTPError("Channel not found", 404); + + const type: ChannelType = channel.type; + + getPermission(req.userid, channel.guild_id, channel_id); + + if (channel.guild_id) { + channel.permission_overwrites; + } else if (channel.recipients) { + // group/dm channel + } else { + // idk what this channel is, can probably be removed + } +}); diff --git a/src/routes/api/v8/channels/#CHANNELID/permissions.ts b/src/routes/api/v8/channels/#channel_id/permissions.ts similarity index 100% rename from src/routes/api/v8/channels/#CHANNELID/permissions.ts rename to src/routes/api/v8/channels/#channel_id/permissions.ts diff --git a/src/routes/api/v8/channels/#CHANNELID/pins.ts b/src/routes/api/v8/channels/#channel_id/pins.ts similarity index 100% rename from src/routes/api/v8/channels/#CHANNELID/pins.ts rename to src/routes/api/v8/channels/#channel_id/pins.ts diff --git a/src/routes/api/v8/channels/#CHANNELID/recipients.ts b/src/routes/api/v8/channels/#channel_id/recipients.ts similarity index 100% rename from src/routes/api/v8/channels/#CHANNELID/recipients.ts rename to src/routes/api/v8/channels/#channel_id/recipients.ts diff --git a/src/routes/api/v8/channels/#CHANNELID/typing.ts b/src/routes/api/v8/channels/#channel_id/typing.ts similarity index 100% rename from src/routes/api/v8/channels/#CHANNELID/typing.ts rename to src/routes/api/v8/channels/#channel_id/typing.ts diff --git a/src/routes/api/v8/channels/#CHANNELID/webhooks.ts b/src/routes/api/v8/channels/#channel_id/webhooks.ts similarity index 100% rename from src/routes/api/v8/channels/#CHANNELID/webhooks.ts rename to src/routes/api/v8/channels/#channel_id/webhooks.ts