summary refs log tree commit diff
path: root/src/gateway/opcodes/Identify.ts
diff options
context:
space:
mode:
Diffstat (limited to 'src/gateway/opcodes/Identify.ts')
-rw-r--r--src/gateway/opcodes/Identify.ts9
1 files changed, 7 insertions, 2 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);