diff options
author | AlTech98 <altech123159@gmail.com> | 2021-09-14 09:38:52 +0200 |
---|---|---|
committer | AlTech98 <altech123159@gmail.com> | 2021-09-14 09:38:52 +0200 |
commit | b5f2111d207d1c7e61149c5ce1afb174a5bb23c3 (patch) | |
tree | a58eff1e61962fe9fdedfc74a0933f811d2ad90b /api/src/routes | |
parent | Fix invites creation (diff) | |
download | server-b5f2111d207d1c7e61149c5ce1afb174a5bb23c3.tar.xz |
Emit INVITE_DELETE
Diffstat (limited to 'api/src/routes')
-rw-r--r-- | api/src/routes/invites/index.ts | 17 |
1 files changed, 15 insertions, 2 deletions
diff --git a/api/src/routes/invites/index.ts b/api/src/routes/invites/index.ts index 6e77a853..ae8a5944 100644 --- a/api/src/routes/invites/index.ts +++ b/api/src/routes/invites/index.ts @@ -1,7 +1,8 @@ import { Router, Request, Response } from "express"; -import { getPermission, Guild, Invite, Member, PublicInviteRelation } from "@fosscord/util"; +import { emitEvent, getPermission, Guild, Invite, InviteDeleteEvent, Member, PublicInviteRelation } from "@fosscord/util"; import { route } from "@fosscord/api"; import { HTTPError } from "lambert-server"; + const router: Router = Router(); router.get("/:code", route({}), async (req: Request, res: Response) => { @@ -35,7 +36,19 @@ router.delete("/:code", route({}), async (req: Request, res: Response) => { if (!permission.has("MANAGE_GUILD") && !permission.has("MANAGE_CHANNELS")) throw new HTTPError("You missing the MANAGE_GUILD or MANAGE_CHANNELS permission", 401); - await Promise.all([Invite.delete({ code }), Guild.update({ vanity_url_code: code }, { vanity_url_code: undefined })]); + await Promise.all([ + Invite.delete({ code }), + Guild.update({ vanity_url_code: code }, { vanity_url_code: undefined }), + emitEvent({ + event: "INVITE_DELETE", + guild_id: guild_id, + data: { + channel_id: channel_id, + guild_id: guild_id, + code: code + } + } as InviteDeleteEvent) + ]); res.json({ invite: invite }); }); |