summary refs log tree commit diff
path: root/api/src/routes/channels/#channel_id
diff options
context:
space:
mode:
Diffstat (limited to 'api/src/routes/channels/#channel_id')
-rw-r--r--api/src/routes/channels/#channel_id/index.ts3
-rw-r--r--api/src/routes/channels/#channel_id/invites.ts3
-rw-r--r--api/src/routes/channels/#channel_id/messages/#message_id/ack.ts3
-rw-r--r--api/src/routes/channels/#channel_id/recipients.ts3
4 files changed, 8 insertions, 4 deletions
diff --git a/api/src/routes/channels/#channel_id/index.ts b/api/src/routes/channels/#channel_id/index.ts
index 4001b834..68b52be6 100644
--- a/api/src/routes/channels/#channel_id/index.ts
+++ b/api/src/routes/channels/#channel_id/index.ts
@@ -10,6 +10,7 @@ import {
 } from "@fosscord/util";
 import { Request, Response, Router } from "express";
 import { route } from "@fosscord/api";
+import { OrmUtils } from "@fosscord/util";
 
 const router: Router = Router();
 // TODO: delete channel
@@ -78,7 +79,7 @@ router.patch("/", route({ body: "ChannelModifySchema", permission: "MANAGE_CHANN
 	if (payload.icon) payload.icon = await handleFile(`/channel-icons/${channel_id}`, payload.icon);
 
 	let channel = await Channel.findOneOrFail({ where: { id: channel_id } });
-	channel = Object.assign(channel, payload);
+	channel = OrmUtils.mergeDeep(channel, payload);
 
 	await Promise.all([
 		channel.save(),
diff --git a/api/src/routes/channels/#channel_id/invites.ts b/api/src/routes/channels/#channel_id/invites.ts
index 4e97b275..a53b1de4 100644
--- a/api/src/routes/channels/#channel_id/invites.ts
+++ b/api/src/routes/channels/#channel_id/invites.ts
@@ -4,6 +4,7 @@ import { route } from "@fosscord/api";
 import { random } from "@fosscord/api";
 import { Channel, Invite, InviteCreateEvent, emitEvent, User, Guild, PublicInviteRelation } from "@fosscord/util";
 import { isTextChannel } from "./messages";
+import { OrmUtils } from "@fosscord/util";
 
 const router: Router = Router();
 
@@ -33,7 +34,7 @@ router.post("/", route({ body: "InviteCreateSchema", permission: "CREATE_INSTANT
 
 	const expires_at = new Date(req.body.max_age * 1000 + Date.now());
 
-	const invite = await Object.assign(new Invite(),{
+	const invite = await OrmUtils.mergeDeep(new Invite(),{
 		code: random(),
 		temporary: req.body.temporary,
 		uses: 0,
diff --git a/api/src/routes/channels/#channel_id/messages/#message_id/ack.ts b/api/src/routes/channels/#channel_id/messages/#message_id/ack.ts
index fc2ec488..c1b8d20f 100644
--- a/api/src/routes/channels/#channel_id/messages/#message_id/ack.ts
+++ b/api/src/routes/channels/#channel_id/messages/#message_id/ack.ts
@@ -1,6 +1,7 @@
 import { emitEvent, getPermission, MessageAckEvent, ReadState, Snowflake } from "@fosscord/util";
 import { Request, Response, Router } from "express";
 import { route } from "@fosscord/api";
+import { OrmUtils } from "@fosscord/util";
 
 const router = Router();
 
@@ -20,7 +21,7 @@ router.post("/", route({ body: "MessageAcknowledgeSchema" }), async (req: Reques
 	permission.hasThrow("VIEW_CHANNEL");
 
 	let read_state = await ReadState.findOne({ where: { user_id: req.user_id, channel_id } });
-	if (!read_state) read_state = Object.assign(new ReadState(), { user_id: req.user_id, channel_id });
+	if (!read_state) read_state = OrmUtils.mergeDeep(new ReadState(), { user_id: req.user_id, channel_id }) as ReadState;
 	read_state.last_message_id = message_id;
 
 	await read_state.save();
diff --git a/api/src/routes/channels/#channel_id/recipients.ts b/api/src/routes/channels/#channel_id/recipients.ts
index d6e25599..069212e2 100644
--- a/api/src/routes/channels/#channel_id/recipients.ts
+++ b/api/src/routes/channels/#channel_id/recipients.ts
@@ -11,6 +11,7 @@ import {
 	User
 } from "@fosscord/util";
 import { route } from "@fosscord/api";
+import { OrmUtils } from "@fosscord/util";
 
 const router: Router = Router();
 
@@ -28,7 +29,7 @@ router.put("/:user_id", route({}), async (req: Request, res: Response) => {
 			throw DiscordApiErrors.INVALID_RECIPIENT; //TODO is this the right error?
 		}
 
-		channel.recipients!.push(Object.assign(new Recipient(), { channel_id, user_id: user_id }));
+		channel.recipients!.push(OrmUtils.mergeDeep(new Recipient(), { channel_id, user_id: user_id }));
 		await channel.save();
 
 		await emitEvent({