Move UserSettings to own entity

This commit is contained in:
TheArcaneBrony
2022-12-19 17:52:44 +11:00
committed by Madeline
parent d407d8ebe7
commit 803ab38fad
12 changed files with 2914 additions and 207 deletions
+7 -2
View File
@@ -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);
+5 -1
View File
@@ -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