mirror of
https://github.com/spacebarchat/server.git
synced 2024-11-07 19:32:34 +01:00
🐛 fix getPublicUser
This commit is contained in:
parent
ea58f5b535
commit
711dc1c4d4
@ -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;
|
||||
})
|
||||
|
@ -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);
|
||||
|
Loading…
Reference in New Issue
Block a user