mirror of
https://github.com/spacebarchat/server.git
synced 2024-09-21 18:21:36 +02:00
commit
a8943553f9
@ -713,7 +713,10 @@
|
|||||||
"type": "object",
|
"type": "object",
|
||||||
"properties": {
|
"properties": {
|
||||||
"target_user_id": {
|
"target_user_id": {
|
||||||
"type": "string"
|
"type": [
|
||||||
|
"null",
|
||||||
|
"string"
|
||||||
|
]
|
||||||
},
|
},
|
||||||
"target_type": {
|
"target_type": {
|
||||||
"type": [
|
"type": [
|
||||||
|
@ -8,7 +8,7 @@ import { isTextChannel } from "./messages";
|
|||||||
const router: Router = Router();
|
const router: Router = Router();
|
||||||
|
|
||||||
export interface InviteCreateSchema {
|
export interface InviteCreateSchema {
|
||||||
target_user_id?: string;
|
target_user_id?: string | null;
|
||||||
target_type?: string | null;
|
target_type?: string | null;
|
||||||
validate?: string | null; // ? what is this
|
validate?: string | null; // ? what is this
|
||||||
max_age?: number;
|
max_age?: number;
|
||||||
|
@ -1,7 +1,8 @@
|
|||||||
import { Router, Request, Response } from "express";
|
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 { route } from "@fosscord/api";
|
||||||
import { HTTPError } from "lambert-server";
|
import { HTTPError } from "lambert-server";
|
||||||
|
|
||||||
const router: Router = Router();
|
const router: Router = Router();
|
||||||
|
|
||||||
router.get("/:code", route({}), async (req: Request, res: Response) => {
|
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"))
|
if (!permission.has("MANAGE_GUILD") && !permission.has("MANAGE_CHANNELS"))
|
||||||
throw new HTTPError("You missing the MANAGE_GUILD or MANAGE_CHANNELS permission", 401);
|
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 });
|
res.json({ invite: invite });
|
||||||
});
|
});
|
||||||
|
Loading…
Reference in New Issue
Block a user