diff options
author | Flam3rboy <34555296+Flam3rboy@users.noreply.github.com> | 2021-09-04 11:25:10 +0200 |
---|---|---|
committer | Flam3rboy <34555296+Flam3rboy@users.noreply.github.com> | 2021-09-04 11:25:10 +0200 |
commit | 4de2140058f72efdabd4496cf7bd727960b2ed90 (patch) | |
tree | 0574a4d02fb04e85efc42ca72652c244e3ca222a | |
parent | :bug: fix permissions if user is only member of guild (diff) | |
download | server-4de2140058f72efdabd4496cf7bd727960b2ed90.tar.xz |
:bug: fix invites
-rw-r--r-- | api/src/routes/channels/#channel_id/invites.ts | 7 | ||||
-rw-r--r-- | api/src/routes/guilds/#guild_id/invites.ts | 4 | ||||
-rw-r--r-- | api/src/routes/invites/index.ts | 4 | ||||
-rw-r--r-- | util/src/entities/Invite.ts | 2 |
4 files changed, 8 insertions, 9 deletions
diff --git a/api/src/routes/channels/#channel_id/invites.ts b/api/src/routes/channels/#channel_id/invites.ts index fcc8a1ad..fe22d3bc 100644 --- a/api/src/routes/channels/#channel_id/invites.ts +++ b/api/src/routes/channels/#channel_id/invites.ts @@ -1,12 +1,9 @@ import { Router, Request, Response } from "express"; import { HTTPError } from "lambert-server"; - import { check } from "../../../util/instanceOf"; import { random } from "../../../util/RandomInviteID"; - import { InviteCreateSchema } from "../../../schema/Invite"; - -import { getPermission, Channel, Invite, InviteCreateEvent, emitEvent, User, Guild } from "@fosscord/util"; +import { getPermission, Channel, Invite, InviteCreateEvent, emitEvent, User, Guild, PublicInviteRelation } from "@fosscord/util"; import { isTextChannel } from "./messages"; const router: Router = Router(); @@ -74,7 +71,7 @@ router.get("/", async (req: Request, res: Response) => { const permission = await getPermission(user_id, guild_id); permission.hasThrow("MANAGE_CHANNELS"); - const invites = await Invite.find({ guild_id }); + const invites = await Invite.find({ where: { guild_id }, relations: PublicInviteRelation }); res.status(200).send(invites); }); diff --git a/api/src/routes/guilds/#guild_id/invites.ts b/api/src/routes/guilds/#guild_id/invites.ts index 1843b689..39a934ee 100644 --- a/api/src/routes/guilds/#guild_id/invites.ts +++ b/api/src/routes/guilds/#guild_id/invites.ts @@ -1,4 +1,4 @@ -import { getPermission, Invite } from "@fosscord/util"; +import { getPermission, Invite, PublicInviteRelation } from "@fosscord/util"; import { Request, Response, Router } from "express"; const router = Router(); @@ -9,7 +9,7 @@ router.get("/", async (req: Request, res: Response) => { const permissions = await getPermission(req.user_id, guild_id); permissions.hasThrow("MANAGE_GUILD"); - const invites = await Invite.find({ guild_id }); + const invites = await Invite.find({ where: { guild_id }, relations: PublicInviteRelation }); return res.json(invites); }); diff --git a/api/src/routes/invites/index.ts b/api/src/routes/invites/index.ts index 23fa3aec..b8c24c1f 100644 --- a/api/src/routes/invites/index.ts +++ b/api/src/routes/invites/index.ts @@ -1,12 +1,12 @@ import { Router, Request, Response } from "express"; -import { getPermission, Guild, Invite, Member } from "@fosscord/util"; +import { getPermission, Guild, Invite, Member, PublicInviteRelation } from "@fosscord/util"; import { HTTPError } from "lambert-server"; const router: Router = Router(); router.get("/:code", async (req: Request, res: Response) => { const { code } = req.params; - const invite = await Invite.findOneOrFail({ code }); + const invite = await Invite.findOneOrFail({ where: { code }, relations: PublicInviteRelation }); res.status(200).send(invite); }); diff --git a/util/src/entities/Invite.ts b/util/src/entities/Invite.ts index 01e22294..afad9c02 100644 --- a/util/src/entities/Invite.ts +++ b/util/src/entities/Invite.ts @@ -4,6 +4,8 @@ import { Channel } from "./Channel"; import { Guild } from "./Guild"; import { User } from "./User"; +export const PublicInviteRelation = ["inviter", "guild", "channel"]; + @Entity("invites") export class Invite extends BaseClass { @PrimaryColumn() |