diff options
author | stefan080106 <stefan.arnold.programmierung@gmail.com> | 2021-04-26 21:29:19 +0200 |
---|---|---|
committer | stefan080106 <stefan.arnold.programmierung@gmail.com> | 2021-04-26 21:29:19 +0200 |
commit | 1f106e1a37458115e561c3e333dcace2b53c13dd (patch) | |
tree | 29a5ae32ffc78139110f4a58654afd5703f7e701 /src/routes | |
parent | :lock: Fix parent id checking (diff) | |
download | server-1f106e1a37458115e561c3e333dcace2b53c13dd.tar.xz |
:construction: WIP
Diffstat (limited to 'src/routes')
-rw-r--r-- | src/routes/channels/#channel_id/index.ts | 14 |
1 files changed, 9 insertions, 5 deletions
diff --git a/src/routes/channels/#channel_id/index.ts b/src/routes/channels/#channel_id/index.ts index 730c1a67..d1c64267 100644 --- a/src/routes/channels/#channel_id/index.ts +++ b/src/routes/channels/#channel_id/index.ts @@ -1,4 +1,4 @@ -import { ChannelDeleteEvent, ChannelModel, ChannelUpdateEvent, getPermission, toObject } from "@fosscord/server-util"; +import { ChannelDeleteEvent, ChannelModel, ChannelUpdateEvent, getPermission, GuildUpdateEvent, toObject } from "@fosscord/server-util"; import { Router } from "express"; import { HTTPError } from "lambert-server"; import { ChannelModifySchema } from "../../../schema/Channel"; @@ -11,17 +11,21 @@ const router: Router = Router(); router.delete("/", async (req, res) => { const { channel_id } = req.params - const channel = await ChannelModel.findOne({ id: channel_id }, { guild_id: true, type: true, permission_overwrites: true }).exec(); + const channel = await ChannelModel.findOne({ id: channel_id }).exec(); if (!channel) throw new HTTPError("Channel not found", 404); - const permission = await getPermission(req.user_id, channel.guild_id) - permission.hasThrow("MANAGE_CHANNELS") + if (channel.guild_id) { - // TODO Channel Update Gateway event will fire for each of them + const permission = await getPermission(req.user_id, channel.guild_id) + permission.hasThrow("MANAGE_CHANNELS") + } + // TODO Channel Update Gateway event will fire for each of them await ChannelModel.deleteOne({ id: channel_id }) // TODO: Dm channel "close" not delete + + await emitEvent({ event: "CHANNEL_DELETE", data: channel, guild_id: channel_id, channel_id} as ChannelDeleteEvent); const data = toObject(channel); //TODO: Reload channel list if request successful |