From 295159fc4a7d32ffa7686ff7df510d098a1794f9 Mon Sep 17 00:00:00 2001 From: Flam3rboy <34555296+Flam3rboy@users.noreply.github.com> Date: Wed, 1 Sep 2021 23:34:55 +0200 Subject: :bug: fix entity types and projection --- .../#channel_id/messages/#message_id/index.ts | 3 +-- api/src/routes/users/@me/index.ts | 25 ++-------------------- 2 files changed, 3 insertions(+), 25 deletions(-) (limited to 'api/src') diff --git a/api/src/routes/channels/#channel_id/messages/#message_id/index.ts b/api/src/routes/channels/#channel_id/messages/#message_id/index.ts index b9d46c4f..9c631a18 100644 --- a/api/src/routes/channels/#channel_id/messages/#message_id/index.ts +++ b/api/src/routes/channels/#channel_id/messages/#message_id/index.ts @@ -1,7 +1,6 @@ import { Channel, emitEvent, getPermission, MessageDeleteEvent, Message, MessageUpdateEvent } from "@fosscord/util"; import { Router, Response, Request } from "express"; import { MessageCreateSchema } from "../../../../../schema/Message"; - import { check } from "../../../../../util/instanceOf"; import { handleMessage, postHandleMessage } from "../../../../../util/Message"; @@ -32,7 +31,7 @@ router.patch("/", check(MessageCreateSchema), async (req: Request, res: Response }); await Promise.all([ - new_message.save(), + new_message!.save(), await emitEvent({ event: "MESSAGE_UPDATE", channel_id, diff --git a/api/src/routes/users/@me/index.ts b/api/src/routes/users/@me/index.ts index d5a5723c..68649215 100644 --- a/api/src/routes/users/@me/index.ts +++ b/api/src/routes/users/@me/index.ts @@ -1,5 +1,5 @@ import { Router, Request, Response } from "express"; -import { User } from "@fosscord/util"; +import { User, PrivateUserProjection } from "@fosscord/util"; import { UserModifySchema } from "../../../schema/User"; import { check } from "../../../util/instanceOf"; import { handleFile } from "../../../util/cdn"; @@ -7,30 +7,9 @@ import { handleFile } from "../../../util/cdn"; const router: Router = Router(); router.get("/", async (req: Request, res: Response) => { - res.json(await User.getPublicUser(req.user_id)); + res.json(await User.getPublicUser(req.user_id, { select: PrivateUserProjection })); }); -const UserUpdateProjection = [ - "accent_color", - "avatar", - "banner", - "bio", - "bot", - "discriminator", - "email", - "flags", - "id", - "locale", - "mfa_enabled", - "nsfw_alllowed", - "phone", - "public_flags", - "purchased_flags", - // "token", // this isn't saved in the db and needs to be set manually - "username", - "verified" -]; - router.patch("/", check(UserModifySchema), async (req: Request, res: Response) => { const body = req.body as UserModifySchema; -- cgit 1.4.1