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);
|