🚧 messages route
This commit is contained in:
		
							parent
							
								
									5c11bf1b87
								
							
						
					
					
						commit
						4b9f36d344
					
				| @ -1,4 +0,0 @@ | ||||
| import { Router } from "express"; | ||||
| const router: Router = Router(); | ||||
| 
 | ||||
| export default router; | ||||
| @ -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) { | ||||
							
								
								
									
										27
									
								
								src/routes/api/v8/channels/#channel_id/messages.ts
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										27
									
								
								src/routes/api/v8/channels/#channel_id/messages.ts
									
									
									
									
									
										Normal 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
 | ||||
| 	} | ||||
| }); | ||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user
	 Flam3rboy
						Flam3rboy