🚧 Webhook
This commit is contained in:
		
							parent
							
								
									3e6d1103bc
								
							
						
					
					
						commit
						4a2c0ebe5f
					
				| @ -1,5 +1,6 @@ | ||||
| import { Router } from "express"; | ||||
| const router: Router = Router(); | ||||
| // TODO:
 | ||||
| 
 | ||||
| export default router; | ||||
| 
 | ||||
|  | ||||
| @ -1,4 +1,5 @@ | ||||
| import { Router } from "express"; | ||||
| const router: Router = Router(); | ||||
| // TODO:
 | ||||
| 
 | ||||
| export default router; | ||||
|  | ||||
| @ -0,0 +1,6 @@ | ||||
| import { Router } from "express"; | ||||
| 
 | ||||
| const router = Router(); | ||||
| // TODO:
 | ||||
| 
 | ||||
| export default router; | ||||
| @ -0,0 +1,6 @@ | ||||
| import { Router } from "express"; | ||||
| 
 | ||||
| const router = Router(); | ||||
| // TODO:
 | ||||
| 
 | ||||
| export default router; | ||||
| @ -22,7 +22,7 @@ const router: Router = Router(); | ||||
| 
 | ||||
| export default router; | ||||
| 
 | ||||
| function isTextChannel(type: ChannelType): boolean { | ||||
| export function isTextChannel(type: ChannelType): boolean { | ||||
| 	switch (type) { | ||||
| 		case ChannelType.GUILD_VOICE: | ||||
| 		case ChannelType.GUILD_CATEGORY: | ||||
|  | ||||
| @ -1,4 +1,5 @@ | ||||
| import { Router } from "express"; | ||||
| const router: Router = Router(); | ||||
| // TODO:
 | ||||
| 
 | ||||
| export default router; | ||||
|  | ||||
| @ -1,4 +1,5 @@ | ||||
| import { Router } from "express"; | ||||
| const router: Router = Router(); | ||||
| // TODO:
 | ||||
| 
 | ||||
| export default router; | ||||
|  | ||||
| @ -1,4 +1,5 @@ | ||||
| import { Router } from "express"; | ||||
| const router: Router = Router(); | ||||
| // TODO:
 | ||||
| 
 | ||||
| export default router; | ||||
|  | ||||
| @ -1,4 +1,5 @@ | ||||
| import { Router } from "express"; | ||||
| const router: Router = Router(); | ||||
| // TODO:
 | ||||
| 
 | ||||
| export default router; | ||||
|  | ||||
| @ -1,6 +1,27 @@ | ||||
| import { Router } from "express"; | ||||
| const router: Router = Router(); | ||||
| import { check, Length } from "../../../util/instanceOf"; | ||||
| import { ChannelModel, getPermission, trimSpecial } from "@fosscord/server-util"; | ||||
| import { HTTPError } from "lambert-server"; | ||||
| import { isTextChannel } from "./messages/index"; | ||||
| 
 | ||||
| router.post("/", (req, res) => {}); | ||||
| const router: Router = Router(); | ||||
| // TODO:
 | ||||
| 
 | ||||
| // TODO: use Image Data Type for avatar instead of String
 | ||||
| router.post("/", check({ name: new Length(String, 1, 80), $avatar: String }), async (req, res) => { | ||||
| 	const channel_id = req.params.channel_id; | ||||
| 	const channel = await ChannelModel.findOne({ id: channel_id }, { guild_id: true, type: true }).exec(); | ||||
| 	if (!channel) throw new HTTPError("Channel not found", 404); | ||||
| 
 | ||||
| 	isTextChannel(channel.type); | ||||
| 	if (!channel.guild_id) throw new HTTPError("Not a guild channel", 400); | ||||
| 
 | ||||
| 	const permission = await getPermission(req.user_id, channel.guild_id); | ||||
| 	permission.hasThrow("MANAGE_WEBHOOKS"); | ||||
| 
 | ||||
| 	var { avatar, name } = req.body as { name: string; avatar?: string }; | ||||
| 	name = trimSpecial(name); | ||||
| 	if (name === "clyde") throw new HTTPError("Invalid name", 400); | ||||
| }); | ||||
| 
 | ||||
| export default router; | ||||
|  | ||||
| @ -34,6 +34,9 @@ export function FieldErrors(fields: Record<string, { code?: string; message: str | ||||
| 	); | ||||
| } | ||||
| 
 | ||||
| // TODO: implement Image data type: Data URI scheme that supports JPG, GIF, and PNG formats. An example Data URI format is: data:image/jpeg;base64,BASE64_ENCODED_JPEG_IMAGE_DATA
 | ||||
| // Ensure you use the proper content type (image/jpeg, image/png, image/gif) that matches the image data being provided.
 | ||||
| 
 | ||||
| export class FieldError extends Error { | ||||
| 	constructor(public code: string | number, public message: string, public errors?: any) { | ||||
| 		super(message); | ||||
|  | ||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user
	 Flam3rboy
						Flam3rboy