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
35
36
37
38
39
|
import { route } from "@fosscord/api";
import {
emitEvent,
Member,
PrivateUserProjection,
User,
UserDeleteEvent,
UserDeleteSchema,
} from "@fosscord/util";
import { Request, Response, Router } from "express";
const router = Router();
router.post(
"/",
route({ right: "MANAGE_USERS" }),
async (req: Request, res: Response) => {
let user = await User.findOneOrFail({
where: { id: req.params.id },
select: [...PrivateUserProjection, "data"],
});
await Promise.all([
Member.delete({ id: req.params.id }),
User.delete({ id: req.params.id }),
]);
// TODO: respect intents as USER_DELETE has potential to cause privacy issues
await emitEvent({
event: "USER_DELETE",
user_id: req.user_id,
data: { user_id: req.params.id },
} as UserDeleteEvent);
res.sendStatus(204);
},
);
export default router;
|