summary refs log tree commit diff
diff options
context:
space:
mode:
authorRory& <root@rory.gay>2025-12-16 08:15:10 +0100
committerRory& <root@rory.gay>2025-12-16 08:15:10 +0100
commit58da68b89edfc21ce5443b0651a6e68700a929b4 (patch)
treedc0c640c0671f5af8bc9b907911b1b33a1b8bf8d
parentLess debug logging, more useful? (diff)
downloadserver-ts-58da68b89edfc21ce5443b0651a6e68700a929b4.tar.xz
Gateway: update session last seen on heartbeat
-rw-r--r--src/gateway/opcodes/Heartbeat.ts17
1 files changed, 16 insertions, 1 deletions
diff --git a/src/gateway/opcodes/Heartbeat.ts b/src/gateway/opcodes/Heartbeat.ts

index ab222bdf..47e9be52 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<Session> = { + 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<Session>, + newSessionData, + ), + ]); }