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