From 58da68b89edfc21ce5443b0651a6e68700a929b4 Mon Sep 17 00:00:00 2001 From: Rory& Date: Tue, 16 Dec 2025 08:15:10 +0100 Subject: [PATCH] Gateway: update session last seen on heartbeat --- src/gateway/opcodes/Heartbeat.ts | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/src/gateway/opcodes/Heartbeat.ts b/src/gateway/opcodes/Heartbeat.ts index ab222bdf4..47e9be52d 100644 --- a/src/gateway/opcodes/Heartbeat.ts +++ b/src/gateway/opcodes/Heartbeat.ts @@ -19,6 +19,8 @@ import { OPCODES, Payload, WebSocket } from "@spacebar/gateway"; import { setHeartbeat } from "../util/Heartbeat"; import { Send } from "../util/Send"; +import { Session } from "@spacebar/util*"; +import { FindOptionsWhere } from "typeorm"; interface QoSData { seq: number | null; @@ -40,5 +42,18 @@ export async function onHeartbeat(this: WebSocket, data: Payload) { this.qos = (data.d as QoSData).qos; } - await Send(this, { op: 11, d: {} }); + const newSessionData: Partial = { + last_seen: new Date(), + }; + + await Promise.all([ + Send(this, { op: 11, d: {} }), + Session.update( + { + id: this.session_id!, + user_id: this.user_id!, + } as FindOptionsWhere, + newSessionData, + ), + ]); }