summary refs log tree commit diff
diff options
context:
space:
mode:
-rw-r--r--src/routes/channels/#channel_id/followers.ts1
-rw-r--r--src/routes/channels/#channel_id/index.ts1
-rw-r--r--src/routes/channels/#channel_id/messages/:message_id/index.ts6
-rw-r--r--src/routes/channels/#channel_id/messages/:message_id/reactions.ts6
-rw-r--r--src/routes/channels/#channel_id/messages/index.ts2
-rw-r--r--src/routes/channels/#channel_id/permissions.ts1
-rw-r--r--src/routes/channels/#channel_id/pins.ts1
-rw-r--r--src/routes/channels/#channel_id/recipients.ts1
-rw-r--r--src/routes/channels/#channel_id/typing.ts1
-rw-r--r--src/routes/channels/#channel_id/webhooks.ts23
-rw-r--r--src/util/instanceOf.ts3
11 files changed, 44 insertions, 2 deletions
diff --git a/src/routes/channels/#channel_id/followers.ts b/src/routes/channels/#channel_id/followers.ts
index 25165356..c06db61b 100644
--- a/src/routes/channels/#channel_id/followers.ts
+++ b/src/routes/channels/#channel_id/followers.ts
@@ -1,5 +1,6 @@
 import { Router } from "express";
 const router: Router = Router();
+// TODO:
 
 export default router;
 
diff --git a/src/routes/channels/#channel_id/index.ts b/src/routes/channels/#channel_id/index.ts
index 9a4e81fa..93c33ea5 100644
--- a/src/routes/channels/#channel_id/index.ts
+++ b/src/routes/channels/#channel_id/index.ts
@@ -1,4 +1,5 @@
 import { Router } from "express";
 const router: Router = Router();
+// TODO:
 
 export default router;
diff --git a/src/routes/channels/#channel_id/messages/:message_id/index.ts b/src/routes/channels/#channel_id/messages/:message_id/index.ts
index e69de29b..014daee7 100644
--- a/src/routes/channels/#channel_id/messages/:message_id/index.ts
+++ b/src/routes/channels/#channel_id/messages/:message_id/index.ts
@@ -0,0 +1,6 @@
+import { Router } from "express";
+
+const router = Router();
+// TODO:
+
+export default router;
diff --git a/src/routes/channels/#channel_id/messages/:message_id/reactions.ts b/src/routes/channels/#channel_id/messages/:message_id/reactions.ts
index e69de29b..014daee7 100644
--- a/src/routes/channels/#channel_id/messages/:message_id/reactions.ts
+++ b/src/routes/channels/#channel_id/messages/:message_id/reactions.ts
@@ -0,0 +1,6 @@
+import { Router } from "express";
+
+const router = Router();
+// TODO:
+
+export default router;
diff --git a/src/routes/channels/#channel_id/messages/index.ts b/src/routes/channels/#channel_id/messages/index.ts
index 689f6733..712bbc7a 100644
--- a/src/routes/channels/#channel_id/messages/index.ts
+++ b/src/routes/channels/#channel_id/messages/index.ts
@@ -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:
diff --git a/src/routes/channels/#channel_id/permissions.ts b/src/routes/channels/#channel_id/permissions.ts
index 9a4e81fa..93c33ea5 100644
--- a/src/routes/channels/#channel_id/permissions.ts
+++ b/src/routes/channels/#channel_id/permissions.ts
@@ -1,4 +1,5 @@
 import { Router } from "express";
 const router: Router = Router();
+// TODO:
 
 export default router;
diff --git a/src/routes/channels/#channel_id/pins.ts b/src/routes/channels/#channel_id/pins.ts
index 9a4e81fa..93c33ea5 100644
--- a/src/routes/channels/#channel_id/pins.ts
+++ b/src/routes/channels/#channel_id/pins.ts
@@ -1,4 +1,5 @@
 import { Router } from "express";
 const router: Router = Router();
+// TODO:
 
 export default router;
diff --git a/src/routes/channels/#channel_id/recipients.ts b/src/routes/channels/#channel_id/recipients.ts
index 9a4e81fa..93c33ea5 100644
--- a/src/routes/channels/#channel_id/recipients.ts
+++ b/src/routes/channels/#channel_id/recipients.ts
@@ -1,4 +1,5 @@
 import { Router } from "express";
 const router: Router = Router();
+// TODO:
 
 export default router;
diff --git a/src/routes/channels/#channel_id/typing.ts b/src/routes/channels/#channel_id/typing.ts
index 9a4e81fa..93c33ea5 100644
--- a/src/routes/channels/#channel_id/typing.ts
+++ b/src/routes/channels/#channel_id/typing.ts
@@ -1,4 +1,5 @@
 import { Router } from "express";
 const router: Router = Router();
+// TODO:
 
 export default router;
diff --git a/src/routes/channels/#channel_id/webhooks.ts b/src/routes/channels/#channel_id/webhooks.ts
index a7a5df95..a56365b8 100644
--- a/src/routes/channels/#channel_id/webhooks.ts
+++ b/src/routes/channels/#channel_id/webhooks.ts
@@ -1,6 +1,27 @@
 import { Router } from "express";
+import { check, Length } from "../../../util/instanceOf";
+import { ChannelModel, getPermission, trimSpecial } from "@fosscord/server-util";
+import { HTTPError } from "lambert-server";
+import { isTextChannel } from "./messages/index";
+
 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");
 
-router.post("/", (req, res) => {});
+	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;
diff --git a/src/util/instanceOf.ts b/src/util/instanceOf.ts
index b4a231ba..e4e58092 100644
--- a/src/util/instanceOf.ts
+++ b/src/util/instanceOf.ts
@@ -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);