From 271460b02f4b830e02da4799f8a02e3d9e4fd8c7 Mon Sep 17 00:00:00 2001 From: Madeline <46743919+MaddyUnderStars@users.noreply.github.com> Date: Tue, 8 Aug 2023 11:26:32 +1000 Subject: Gateway close if user could not be fetched just send ID --- src/gateway/events/Close.ts | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) 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, -- cgit 1.4.1