mirror of
https://github.com/spacebarchat/server.git
synced 2024-11-14 06:32:36 +01:00
🐛 fix post/patch channel
This commit is contained in:
parent
10913988b9
commit
2bebfa1653
@ -23,15 +23,18 @@ router.get("/", async (req: Request, res: Response) => {
|
|||||||
res.json(toObject(channels));
|
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) => {
|
router.post("/", check(ChannelModifySchema), async (req: Request, res: Response) => {
|
||||||
const { guild_id } = req.params;
|
const { guild_id } = req.params;
|
||||||
const body = req.body as ChannelModifySchema;
|
const body = req.body as ChannelModifySchema;
|
||||||
|
|
||||||
const channel = await createChannel({ ...body, guild_id }, req.user_id);
|
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) => {
|
router.patch("/", check(ChannelModifySchema), async (req: Request, res: Response) => {
|
||||||
const { guild_id } = req.params;
|
const { guild_id } = req.params;
|
||||||
const body = req.body as ChannelModifySchema;
|
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);
|
await emitEvent({ event: "CHANNEL_UPDATE", data: channel } as ChannelUpdateEvent);
|
||||||
|
|
||||||
res.json(channel);
|
res.json(toObject(channel));
|
||||||
});
|
});
|
||||||
|
|
||||||
export default router;
|
export default router;
|
||||||
|
@ -3,7 +3,7 @@ import { Length } from "../util/instanceOf";
|
|||||||
|
|
||||||
export const ChannelModifySchema = {
|
export const ChannelModifySchema = {
|
||||||
name: new Length(String, 2, 100),
|
name: new Length(String, 2, 100),
|
||||||
type: Number,
|
type: new Length(Number, 0, 13),
|
||||||
$topic: new Length(String, 0, 1024),
|
$topic: new Length(String, 0, 1024),
|
||||||
$bitrate: Number,
|
$bitrate: Number,
|
||||||
$user_limit: Number,
|
$user_limit: Number,
|
||||||
|
Loading…
Reference in New Issue
Block a user