blob: 3658e46db6d465e3915d27400abb0a25d1d0464d (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
|
import { UserModel } from "fosscord-server-util";
import { HTTPError } from "lambert-server";
export const PublicUserProjection = {
username: true,
discriminator: true,
id: true,
public_flags: true,
avatar: true,
};
export async function getPublicUser(user_id: bigint, additional_fields?: any) {
const user = await UserModel.findOne(
{ id: user_id },
{
...PublicUserProjection,
...additional_fields,
}
)
.lean()
.exec();
if (!user) throw new HTTPError("User not found", 404);
return user;
}
|