🐛 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)); | ||||
| }); | ||||
| 
 | ||||
| // 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; | ||||
|  | ||||
| @ -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, | ||||
|  | ||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user
	 Flam3rboy
						Flam3rboy