summary refs log tree commit diff
path: root/gateway/src/opcodes
diff options
context:
space:
mode:
authorTheArcaneBrony <myrainbowdash949@gmail.com>2022-08-08 22:49:16 +0200
committerTheArcaneBrony <myrainbowdash949@gmail.com>2022-08-09 23:28:27 +0200
commit26293f37a1f7af131507c0bdd490d2e07f1a9ba7 (patch)
tree3fdaa7b65f1b66069d08d06143a43c9908395a09 /gateway/src/opcodes
parentClean up BaseClient assign call (diff)
downloadserver-26293f37a1f7af131507c0bdd490d2e07f1a9ba7.tar.xz
Use deep merge everywhere
Diffstat (limited to 'gateway/src/opcodes')
-rw-r--r--gateway/src/opcodes/Identify.ts5
-rw-r--r--gateway/src/opcodes/VoiceStateUpdate.ts5
2 files changed, 6 insertions, 4 deletions
diff --git a/gateway/src/opcodes/Identify.ts b/gateway/src/opcodes/Identify.ts
index c6c24fcd..ca081d02 100644
--- a/gateway/src/opcodes/Identify.ts
+++ b/gateway/src/opcodes/Identify.ts
@@ -28,6 +28,7 @@ import { IdentifySchema } from "../schema/Identify";
 const experiments: any = [];
 import { check } from "./instanceOf";
 import { Recipient } from "@fosscord/util";
+import { OrmUtils } from "@fosscord/util";
 
 // TODO: user sharding
 // TODO: check privileged intents, if defined in the config
@@ -50,7 +51,7 @@ export async function onIdentify(this: WebSocket, data: Payload) {
 
 	const session_id = genSessionId();
 	this.session_id = session_id; //Set the session of the WebSocket object
-
+	
 	const [user, read_states, members, recipients, session, application] =
 		await Promise.all([
 			User.findOneOrFail({
@@ -83,7 +84,7 @@ export async function onIdentify(this: WebSocket, data: Payload) {
 				// TODO: public user selection
 			}),
 			// save the session and delete it when the websocket is closed
-			Object.assign(new Session(),{
+			await OrmUtils.mergeDeep(new Session(), {
 				user_id: this.user_id,
 				session_id: session_id,
 				// TODO: check if status is only one of: online, dnd, offline, idle
diff --git a/gateway/src/opcodes/VoiceStateUpdate.ts b/gateway/src/opcodes/VoiceStateUpdate.ts
index 1f7c2f1b..d62425f3 100644
--- a/gateway/src/opcodes/VoiceStateUpdate.ts
+++ b/gateway/src/opcodes/VoiceStateUpdate.ts
@@ -12,6 +12,7 @@ import {
 	VoiceState,
 	VoiceStateUpdateEvent,
 } from "@fosscord/util";
+import { OrmUtils } from "@fosscord/util";
 // TODO: check if a voice server is setup
 // Notice: Bot users respect the voice channel's user limit, if set. When the voice channel is full, you will not receive the Voice State Update or Voice Server Update events in response to your own Voice State Update. Having MANAGE_CHANNELS permission bypasses this limit and allows you to join regardless of the channel being full or not.
 
@@ -47,9 +48,9 @@ export async function onVoiceStateUpdate(this: WebSocket, data: Payload) {
 
 		//The event send by Discord's client on channel leave has both guild_id and channel_id as null
 		if (body.guild_id === null) body.guild_id = voiceState.guild_id;
-		voiceState = Object.assign(voiceState, body);
+		voiceState = OrmUtils.mergeDeep(voiceState, body);
 	} catch (error) {
-		voiceState = Object.assign(new VoiceState(), {
+		voiceState = OrmUtils.mergeDeep(new VoiceState(), {
 			...body,
 			user_id: this.user_id,
 			deaf: false,