1
0
mirror of https://github.com/spacebarchat/server.git synced 2024-11-09 20:22:47 +01:00

Gateway close if user could not be fetched just send ID

This commit is contained in:
Madeline 2023-08-08 11:26:32 +10:00
parent 6dc9dd5303
commit 271460b02f
No known key found for this signature in database
GPG Key ID: 80D25DA3BCB24281

View File

@ -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,