summary refs log tree commit diff
path: root/api/src/routes/channels/#channel_id/messages
diff options
context:
space:
mode:
authorFlam3rboy <34555296+Flam3rboy@users.noreply.github.com>2021-09-13 17:51:16 +0200
committerFlam3rboy <34555296+Flam3rboy@users.noreply.github.com>2021-09-13 17:51:16 +0200
commit0ddca07df000252d778b4830e3dcd2f2a11f5539 (patch)
treee42b282e95bc45fb2f1bbc10ab0c98f2f63fd2c5 /api/src/routes/channels/#channel_id/messages
parent:bug: fix In() query (diff)
downloadserver-0ddca07df000252d778b4830e3dcd2f2a11f5539.tar.xz
:art: remove unused imports
Diffstat (limited to 'api/src/routes/channels/#channel_id/messages')
-rw-r--r--api/src/routes/channels/#channel_id/messages/index.ts17
1 files changed, 6 insertions, 11 deletions
diff --git a/api/src/routes/channels/#channel_id/messages/index.ts b/api/src/routes/channels/#channel_id/messages/index.ts
index 11334367..be9a41b1 100644
--- a/api/src/routes/channels/#channel_id/messages/index.ts
+++ b/api/src/routes/channels/#channel_id/messages/index.ts
@@ -1,7 +1,7 @@
 import { Router, Response, Request } from "express";
 import { Attachment, Channel, ChannelType, Embed, getPermission, Message } from "@fosscord/util";
 import { HTTPError } from "lambert-server";
-import { instanceOf, Length, route } from "@fosscord/api";
+import { route } from "@fosscord/api";
 import multer from "multer";
 import { sendMessage } from "@fosscord/api";
 import { uploadFile } from "@fosscord/api";
@@ -61,17 +61,12 @@ router.get("/", async (req: Request, res: Response) => {
 	if (!channel) throw new HTTPError("Channel not found", 404);
 
 	isTextChannel(channel.type);
+	const around = `${req.query.around}`;
+	const before = `${req.query.before}`;
+	const after = `${req.query.after}`;
+	const limit = Number(req.query.limit) || 50;
+	if (limit < 1 || limit > 100) throw new HTTPError("limit must be between 1 and 100");
 
-	try {
-		instanceOf({ $around: String, $after: String, $before: String, $limit: new Length(Number, 1, 100) }, req.query, {
-			path: "query",
-			req
-		});
-	} catch (error) {
-		return res.status(400).json({ code: 50035, message: "Invalid Query", success: false, errors: error });
-	}
-	var { around, after, before, limit }: { around?: string; after?: string; before?: string; limit?: number } = req.query;
-	if (!limit) limit = 50;
 	var halfLimit = Math.floor(limit / 2);
 
 	const permissions = await getPermission(req.user_id, channel.guild_id, channel_id);