mirror of
https://github.com/spacebarchat/server.git
synced 2024-11-23 02:42:28 +01:00
🐛 fix invites
This commit is contained in:
parent
8d69c9a871
commit
4de2140058
@ -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);
|
||||
});
|
||||
|
@ -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);
|
||||
});
|
||||
|
@ -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);
|
||||
});
|
||||
|
@ -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()
|
||||
|
Loading…
Reference in New Issue
Block a user