1
0
mirror of https://github.com/spacebarchat/server.git synced 2024-09-22 02:31:36 +02:00

invites TTL

This commit is contained in:
Flam3rboy 2021-05-22 17:40:23 +02:00
parent 4715ef1eab
commit f72156a40d

View File

@ -24,16 +24,19 @@ router.post("/", check(InviteCreateSchema), async (req: Request, res: Response)
const permission = await getPermission(user_id, guild_id); const permission = await getPermission(user_id, guild_id);
permission.hasThrow("CREATE_INSTANT_INVITE"); permission.hasThrow("CREATE_INSTANT_INVITE");
const expires_at = new Date(req.body.max_age * 1000 + Date.now());
const invite = { const invite = {
code: random(), code: random(),
temporary: req.body.temporary, temporary: req.body.temporary,
uses: 0, uses: 0,
max_uses: req.body.max_uses, max_uses: req.body.max_uses,
max_age: req.body.max_age, max_age: req.body.max_age,
expires_at,
created_at: new Date(), created_at: new Date(),
guild_id, guild_id,
channel_id: channel_id, channel_id: channel_id,
inviter_id: user_id, inviter_id: user_id
}; };
await new InviteModel(invite).save(); await new InviteModel(invite).save();