Move UserSettings to own entity
This commit is contained in:
@@ -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);
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user