🚧 messages route

This commit is contained in:
Flam3rboy 2021-03-03 21:14:14 +01:00
parent 5c11bf1b87
commit 4b9f36d344
10 changed files with 28 additions and 5 deletions

View File

@ -1,4 +0,0 @@
import { Router } from "express";
const router: Router = Router();
export default router;

View File

@ -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) {

View File

@ -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
}
});