summary refs log tree commit diff
path: root/api/src
diff options
context:
space:
mode:
authorChris Chrome <christophercookman@gmail.com>2021-09-20 08:58:06 -0400
committerChris Chrome <christophercookman@gmail.com>2021-09-20 08:58:06 -0400
commit494f69eeb4f9899d8dd2605f6f812aee2ab5cbfa (patch)
treed200b14b06ab6d8f3ff0547ad06dc2a5f5917ad4 /api/src
parentUpdate README.md (diff)
downloadserver-494f69eeb4f9899d8dd2605f6f812aee2ab5cbfa.tar.xz
Delete messages before deleting channel
Might need some testing, but seems pretty solid for one line of code lol
Diffstat (limited to 'api/src')
-rw-r--r--api/src/routes/channels/#channel_id/index.ts4
1 files changed, 2 insertions, 2 deletions
diff --git a/api/src/routes/channels/#channel_id/index.ts b/api/src/routes/channels/#channel_id/index.ts
index 3f434f5e..ca8cc87c 100644
--- a/api/src/routes/channels/#channel_id/index.ts
+++ b/api/src/routes/channels/#channel_id/index.ts
@@ -1,4 +1,4 @@
-import { Channel, ChannelDeleteEvent, ChannelPermissionOverwriteType, ChannelType, ChannelUpdateEvent, emitEvent, Recipient } from "@fosscord/util";
+import { Channel, Message, ChannelDeleteEvent, ChannelPermissionOverwriteType, ChannelType, ChannelUpdateEvent, emitEvent, Recipient } from "@fosscord/util";
 import { Request, Response, Router } from "express";
 import { handleFile, route } from "@fosscord/api";
 
@@ -30,8 +30,8 @@ router.delete("/", route({ permission: "MANAGE_CHANNELS" }), async (req: Request
 	} else if (channel.type === ChannelType.GROUP_DM) {
 		await Channel.removeRecipientFromChannel(channel, req.user_id)
 	} else {
-		//TODO messages in this channel should be deleted before deleting the channel
 		await Promise.all([
+			Message.delete({ channel_id: channel_id }),
 			Channel.delete({ id: channel_id }),
 			emitEvent({ event: "CHANNEL_DELETE", data: channel, channel_id } as ChannelDeleteEvent)
 		]);