summary refs log tree commit diff
path: root/src
diff options
context:
space:
mode:
authorFlam3rboy <34555296+Flam3rboy@users.noreply.github.com>2021-05-30 22:14:35 +0200
committerFlam3rboy <34555296+Flam3rboy@users.noreply.github.com>2021-05-30 22:14:35 +0200
commit711dc1c4d477849a0f92028f95c123233584bf7f (patch)
treed2418ff320fa26ec1997505a7eda44cf5b3ffb09 /src
parentnpm i @fosscord/server-util@1.3.14 (diff)
downloadserver-711dc1c4d477849a0f92028f95c123233584bf7f.tar.xz
:bug: fix getPublicUser
Diffstat (limited to 'src')
-rw-r--r--src/routes/channels/#channel_id/messages/index.ts2
-rw-r--r--src/util/User.ts12
2 files changed, 5 insertions, 9 deletions
diff --git a/src/routes/channels/#channel_id/messages/index.ts b/src/routes/channels/#channel_id/messages/index.ts

index 4bf1516d..966244ac 100644 --- a/src/routes/channels/#channel_id/messages/index.ts +++ b/src/routes/channels/#channel_id/messages/index.ts
@@ -75,6 +75,8 @@ router.get("/", async (req, res) => { // @ts-ignore delete x.user_ids; }); + // @ts-ignore + if (!x.author) x.author = { discriminator: "0000", username: "Deleted User", public_flags: 0n, avatar: null }; return x; }) diff --git a/src/util/User.ts b/src/util/User.ts
index 0f3768cc..107fc759 100644 --- a/src/util/User.ts +++ b/src/util/User.ts
@@ -1,20 +1,14 @@ -import { toObject, UserModel } from "@fosscord/server-util"; +import { toObject, UserModel, PublicUserProjection } from "@fosscord/server-util"; import { HTTPError } from "lambert-server"; -export const PublicUserProjection = { - username: true, - discriminator: true, - id: true, - public_flags: true, - avatar: true, -}; +export { PublicUserProjection }; export async function getPublicUser(user_id: string, additional_fields?: any) { const user = await UserModel.findOne( { id: user_id }, { ...PublicUserProjection, - ...additional_fields, + ...additional_fields } ).exec(); if (!user) throw new HTTPError("User not found", 404);