summary refs log tree commit diff
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--src/routes/guilds/#guild_id/channels.ts7
-rw-r--r--src/schema/Channel.ts2
2 files changed, 6 insertions, 3 deletions
diff --git a/src/routes/guilds/#guild_id/channels.ts b/src/routes/guilds/#guild_id/channels.ts
index 90b4473d..15cc7394 100644
--- a/src/routes/guilds/#guild_id/channels.ts
+++ b/src/routes/guilds/#guild_id/channels.ts
@@ -23,15 +23,18 @@ router.get("/", async (req: Request, res: Response) => {
 	res.json(toObject(channels));
 });
 
+// TODO: check if channel type is permitted
+// TODO: check if parent_id exists
 router.post("/", check(ChannelModifySchema), async (req: Request, res: Response) => {
 	const { guild_id } = req.params;
 	const body = req.body as ChannelModifySchema;
 
 	const channel = await createChannel({ ...body, guild_id }, req.user_id);
 
-	res.json(channel);
+	res.json(toObject(channel));
 });
 
+// TODO: check if parent_id exists
 router.patch("/", check(ChannelModifySchema), async (req: Request, res: Response) => {
 	const { guild_id } = req.params;
 	const body = req.body as ChannelModifySchema;
@@ -41,7 +44,7 @@ router.patch("/", check(ChannelModifySchema), async (req: Request, res: Response
 
 	await emitEvent({ event: "CHANNEL_UPDATE", data: channel } as ChannelUpdateEvent);
 
-	res.json(channel);
+	res.json(toObject(channel));
 });
 
 export default router;
diff --git a/src/schema/Channel.ts b/src/schema/Channel.ts
index 2cb7f7f4..48c3a1d2 100644
--- a/src/schema/Channel.ts
+++ b/src/schema/Channel.ts
@@ -3,7 +3,7 @@ import { Length } from "../util/instanceOf";
 
 export const ChannelModifySchema = {
 	name: new Length(String, 2, 100),
-	type: Number,
+	type: new Length(Number, 0, 13),
 	$topic: new Length(String, 0, 1024),
 	$bitrate: Number,
 	$user_limit: Number,