summary refs log tree commit diff
diff options
context:
space:
mode:
authorMadeline <46743919+MaddyUnderStars@users.noreply.github.com>2023-08-08 11:26:32 +1000
committerMadeline <46743919+MaddyUnderStars@users.noreply.github.com>2023-08-08 11:26:32 +1000
commit271460b02f4b830e02da4799f8a02e3d9e4fd8c7 (patch)
tree78c82cc939c25f9711254dcadba3e36b50fbef2a
parentfix reversed check in GET messages (diff)
downloadserver-271460b02f4b830e02da4799f8a02e3d9e4fd8c7.tar.xz
Gateway close if user could not be fetched just send ID
-rw-r--r--src/gateway/events/Close.ts10
1 files changed, 9 insertions, 1 deletions
diff --git a/src/gateway/events/Close.ts b/src/gateway/events/Close.ts
index 572037af..16f6b188 100644
--- a/src/gateway/events/Close.ts
+++ b/src/gateway/events/Close.ts
@@ -54,11 +54,19 @@ export async function Close(this: WebSocket, code: number, reason: Buffer) {
 			status: "offline",
 		};
 
+		// TODO
+		// If a user was deleted, they may still be connected to gateway,
+		// which will cause this to throw when they disconnect.
+		// just send the ID of the user instead of the full correct payload for now
+		const userOrId = await User.getPublicUser(this.user_id).catch(() => ({
+			id: this.user_id,
+		}));
+
 		await emitEvent({
 			event: "PRESENCE_UPDATE",
 			user_id: this.user_id,
 			data: {
-				user: await User.getPublicUser(this.user_id),
+				user: userOrId,
 				activities: session.activities,
 				client_status: session?.client_info,
 				status: session.status,