diff options
author | TheArcaneBrony <myrainbowdash949@gmail.com> | 2022-08-12 01:46:42 +0200 |
---|---|---|
committer | Madeline <46743919+MaddyUnderStars@users.noreply.github.com> | 2022-12-19 17:52:44 +1100 |
commit | 803ab38fad68d62493dfd8395f5160ac8176a1b5 (patch) | |
tree | 75994ec356061d62bce0b948167d93587a04bc6d /src/gateway/opcodes | |
parent | Add additional config (diff) | |
download | server-803ab38fad68d62493dfd8395f5160ac8176a1b5.tar.xz |
Move UserSettings to own entity
Diffstat (limited to 'src/gateway/opcodes')
-rw-r--r-- | src/gateway/opcodes/Identify.ts | 9 | ||||
-rw-r--r-- | src/gateway/opcodes/VoiceStateUpdate.ts | 6 |
2 files changed, 12 insertions, 3 deletions
diff --git a/src/gateway/opcodes/Identify.ts b/src/gateway/opcodes/Identify.ts index fc183286..5f569fee 100644 --- a/src/gateway/opcodes/Identify.ts +++ b/src/gateway/opcodes/Identify.ts @@ -18,9 +18,10 @@ import { PrivateSessionProjection, MemberPrivateProjection, PresenceUpdateEvent, + UserSettings, + IdentifySchema, DefaultUserGuildSettings, UserGuildSettings, - IdentifySchema, } from "@fosscord/util"; import { Send } from "../util/Send"; import { CLOSECODES, OPCODES } from "../util/Constants"; @@ -60,7 +61,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 } }), @@ -105,6 +106,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/src/gateway/opcodes/VoiceStateUpdate.ts b/src/gateway/opcodes/VoiceStateUpdate.ts index 94cdef44..49d15425 100644 --- a/src/gateway/opcodes/VoiceStateUpdate.ts +++ b/src/gateway/opcodes/VoiceStateUpdate.ts @@ -62,7 +62,11 @@ export async function onVoiceStateUpdate(this: WebSocket, data: Payload) { } // 'Fix' for this one voice state error. TODO: Find out why this is sent - if (!voiceState.guild_id) return; + // It seems to be sent on client load, + // so maybe its trying to find which server you were connected to before disconnecting, if any? + if (body.guild_id == null) { + return; + } //TODO the member should only have these properties: hoisted_role, deaf, joined_at, mute, roles, user //TODO the member.user should only have these properties: avatar, discriminator, id, username |