summary refs log tree commit diff
path: root/gateway/src
diff options
context:
space:
mode:
authorTheArcaneBrony <myrainbowdash949@gmail.com>2022-08-12 01:46:42 +0200
committerTheArcaneBrony <myrainbowdash949@gmail.com>2022-08-13 21:57:51 +0200
commit44859db499f080e3a341f3e7fa5e44611fc2f887 (patch)
treee1f5df7de00929797de517683ff152e5f712bd02 /gateway/src
parentMake ConfigValue a directory, move defaults to those classes instead of a sep... (diff)
downloadserver-44859db499f080e3a341f3e7fa5e44611fc2f887.tar.xz
Push local state...
Diffstat (limited to '')
-rw-r--r--gateway/src/opcodes/Identify.ts7
-rw-r--r--gateway/src/opcodes/VoiceStateUpdate.ts5
2 files changed, 11 insertions, 1 deletions
diff --git a/gateway/src/opcodes/Identify.ts b/gateway/src/opcodes/Identify.ts

index 03fff796..4e275592 100644 --- a/gateway/src/opcodes/Identify.ts +++ b/gateway/src/opcodes/Identify.ts
@@ -18,6 +18,7 @@ import { PrivateSessionProjection, MemberPrivateProjection, PresenceUpdateEvent, + UserSettings, } from "@fosscord/util"; import { Send } from "../util/Send"; import { CLOSECODES, OPCODES } from "../util/Constants"; @@ -56,7 +57,7 @@ export async function onIdentify(this: WebSocket, data: Payload) { await Promise.all([ User.findOneOrFail({ where: { id: this.user_id }, - relations: ["relationships", "relationships.to"], + relations: ["relationships", "relationships.to", "settings"], select: [...PrivateUserProjection, "relationships"], }), ReadState.find({ where: { user_id: this.user_id } }), @@ -101,6 +102,10 @@ export async function onIdentify(this: WebSocket, data: Payload) { ]); if (!user) return this.close(CLOSECODES.Authentication_failed); + if (!user.settings) { + user.settings = new UserSettings(); + await user.settings.save(); + } if (!identify.intents) identify.intents = BigInt("0x6ffffffff"); this.intents = new Intents(identify.intents); diff --git a/gateway/src/opcodes/VoiceStateUpdate.ts b/gateway/src/opcodes/VoiceStateUpdate.ts
index 8c430d56..845a75c0 100644 --- a/gateway/src/opcodes/VoiceStateUpdate.ts +++ b/gateway/src/opcodes/VoiceStateUpdate.ts
@@ -20,6 +20,11 @@ export async function onVoiceStateUpdate(this: WebSocket, data: Payload) { check.call(this, VoiceStateUpdateSchema, data.d); const body = data.d as VoiceStateUpdateSchema; + if(body.guild_id == null) { + console.log(`[Gateway] VoiceStateUpdate called with guild_id == null by user ${this.user_id}!`); + return; + } + let voiceState: VoiceState; try { voiceState = await VoiceState.findOneOrFail({