summary refs log tree commit diff
diff options
context:
space:
mode:
-rw-r--r--api/src/routes/channels/#channel_id/index.ts5
-rw-r--r--api/src/routes/users/@me/relationships.ts2
-rw-r--r--api/src/util/route.ts1
3 files changed, 6 insertions, 2 deletions
diff --git a/api/src/routes/channels/#channel_id/index.ts b/api/src/routes/channels/#channel_id/index.ts
index ca8cc87c..9a3cb4c2 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, Message, ChannelDeleteEvent, ChannelPermissionOverwriteType, ChannelType, ChannelUpdateEvent, emitEvent, Recipient } from "@fosscord/util";
+import { Channel, Message, Invite, ReadState, ChannelDeleteEvent, ChannelPermissionOverwriteType, ChannelType, ChannelUpdateEvent, emitEvent, Recipient } from "@fosscord/util";
 import { Request, Response, Router } from "express";
 import { handleFile, route } from "@fosscord/api";
 
@@ -32,6 +32,9 @@ router.delete("/", route({ permission: "MANAGE_CHANNELS" }), async (req: Request
 	} else {
 		await Promise.all([
 			Message.delete({ channel_id: channel_id }),
+			Invite.delete({ channel_id: channel_id }),
+			Recipient.delete({ channel_id: channel_id }),
+			ReadState.delete({ channel_id: channel_id }),
 			Channel.delete({ id: channel_id }),
 			emitEvent({ event: "CHANNEL_DELETE", data: channel, channel_id } as ChannelDeleteEvent)
 		]);
diff --git a/api/src/routes/users/@me/relationships.ts b/api/src/routes/users/@me/relationships.ts
index 1d72f11a..6ad873a6 100644
--- a/api/src/routes/users/@me/relationships.ts
+++ b/api/src/routes/users/@me/relationships.ts
@@ -59,7 +59,7 @@ router.post("/", route({ body: "RelationshipPostSchema" }), async (req: Request,
 			relations: ["relationships", "relationships.to"],
 			select: userProjection,
 			where: {
-				discriminator: String(req.body.discriminator,).padStart(4, '0'), //Discord send the discriminator as integer, we need to add leading zeroes
+				discriminator: String(req.body.discriminator).padStart(4, '0'), //Discord send the discriminator as integer, we need to add leading zeroes
 				username: req.body.username
 			}
 		}),
diff --git a/api/src/util/route.ts b/api/src/util/route.ts
index 678ca64c..b7e6296b 100644
--- a/api/src/util/route.ts
+++ b/api/src/util/route.ts
@@ -14,6 +14,7 @@ export const ajv = new Ajv({
 	parseDate: true,
 	allowDate: true,
 	schemas,
+	coerceTypes: true,
 	messages: true,
 	strict: true,
 	strictRequired: true