summary refs log tree commit diff
path: root/api/src/routes/users/@me/channels.ts
diff options
context:
space:
mode:
authorFlam3rboy <34555296+Flam3rboy@users.noreply.github.com>2021-09-12 23:32:55 +0200
committerFlam3rboy <34555296+Flam3rboy@users.noreply.github.com>2021-09-12 23:32:55 +0200
commitf93bd1fd67f38cd9dc9250f328bb1b8e1214e37c (patch)
tree9e8b85cbad3dbf65e4e4a1162f68163c72b3aea2 /api/src/routes/users/@me/channels.ts
parentMerge pull request #353 from AlTech98/dummy-routes (diff)
parent:sparkles: #307 done (diff)
downloadserver-f93bd1fd67f38cd9dc9250f328bb1b8e1214e37c.tar.xz
Merge branch 'typescript-interface-body-parser+autogenerate-unit-tests+documentation'
Diffstat (limited to 'api/src/routes/users/@me/channels.ts')
-rw-r--r--api/src/routes/users/@me/channels.ts16
1 files changed, 9 insertions, 7 deletions
diff --git a/api/src/routes/users/@me/channels.ts b/api/src/routes/users/@me/channels.ts
index 6fd396b8..5515a217 100644
--- a/api/src/routes/users/@me/channels.ts
+++ b/api/src/routes/users/@me/channels.ts
@@ -1,21 +1,23 @@
 import { Router, Request, Response } from "express";
-import { Channel, ChannelCreateEvent, ChannelType, Snowflake, trimSpecial, User, emitEvent } from "@fosscord/util";
+import { Channel, ChannelCreateEvent, ChannelType, Snowflake, trimSpecial, User, emitEvent, Recipient } from "@fosscord/util";
 import { HTTPError } from "lambert-server";
-
-import { DmChannelCreateSchema } from "../../../schema/Channel";
-import { check } from "../../../util/instanceOf";
+import { route } from "@fosscord/api";
 import { In } from "typeorm";
-import { Recipient } from "../../../../../util/dist/entities/Recipient";
+
+export interface DmChannelCreateSchema {
+	name?: string;
+	recipients: string[];
+}
 
 const router: Router = Router();
 
-router.get("/", async (req: Request, res: Response) => {
+router.get("/", route({}), async (req: Request, res: Response) => {
 	const recipients = await Recipient.find({ where: { user_id: req.user_id }, relations: ["channel"] });
 
 	res.json(recipients.map((x) => x.channel));
 });
 
-router.post("/", check(DmChannelCreateSchema), async (req: Request, res: Response) => {
+router.post("/", route({ body: "DmChannelCreateSchema" }), async (req: Request, res: Response) => {
 	const body = req.body as DmChannelCreateSchema;
 
 	body.recipients = body.recipients.filter((x) => x !== req.user_id).unique();