summary refs log tree commit diff
path: root/src/api/routes/users/@me/profile.ts
blob: 95aa8e6bc0db0179a0c28cbdecca90ca1395a50c (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
25
26
27
28
29
30
31
32
33
34
// import { route } from "@fosscord/api";
// import { emitEvent, handleFile, OrmUtils, PrivateUserProjection, User, UserUpdateEvent } from "@fosscord/util";
// import { Request, Response, Router } from "express";
// import { UserProfileModifySchema } from "../../../../util/schemas/UserProfileModifySchema";

// const router: Router = Router();

// router.patch("/", route({ body: "UserProfileModifySchema" }), async (req: Request, res: Response) => {
// 	const body = req.body as UserProfileModifySchema;

// 	if (body.banner) body.banner = await handleFile(`/banners/${req.user_id}`, body.banner as string);
// 	let user = await User.findOneOrFail({ where: { id: req.user_id }, select: [...PrivateUserProjection, "data"] });

// 	user = OrmUtils.mergeDeep(user, body);
// 	await user.save();

// 	// @ts-ignore
// 	delete user.data;

// 	// TODO: send update member list event in gateway
// 	await emitEvent({
// 		event: "USER_UPDATE",
// 		user_id: req.user_id,
// 		data: user
// 	} as UserUpdateEvent);

// 	res.json({
// 		accent_color: user.accent_color,
// 		bio: user.bio,
// 		banner: user.banner
// 	});
// });

// export default router;