From ca02ca690b33731e2f1f3ca496bbfcf2d7378ac4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Intevel=20=E3=83=84?= <59223342+Intevel@users.noreply.github.com> Date: Sat, 24 Apr 2021 09:58:38 +0200 Subject: [PATCH] get /users/@me/channels --- src/routes/users/@me/channels.ts | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) create mode 100644 src/routes/users/@me/channels.ts diff --git a/src/routes/users/@me/channels.ts b/src/routes/users/@me/channels.ts new file mode 100644 index 00000000..8f2cb74d --- /dev/null +++ b/src/routes/users/@me/channels.ts @@ -0,0 +1,20 @@ +import { Router, Request, Response } from "express"; +import { ChannelModel, MemberModel, UserModel, GuildDeleteEvent, GuildMemberRemoveEvent, toObject } from "@fosscord/server-util"; +import { HTTPError } from "lambert-server"; +import { emitEvent } from "../../../util/Event"; +import { getPublicUser } from "../../../util/User"; + +const router: Router = Router(); + +router.get("/", async (req: Request, res: Response) => { + const user = await UserModel.findOne({ id: req.user_id }, { guilds: true }).exec(); + if (!user) throw new HTTPError("User not found", 404); + + var testID = "829044530203328513"; //FOR TEST + + var channels = await ChannelModel.find({ recipients: req.user_id }).exec(); + + res.json(toObject(channels)); +}); + +export default router; \ No newline at end of file