From 0ea7d5f35cba312545d56bee8abc878fe34383a0 Mon Sep 17 00:00:00 2001 From: Flam3rboy <34555296+Flam3rboy@users.noreply.github.com> Date: Sun, 17 Oct 2021 00:39:54 +0200 Subject: :sparkles: User presence/status --- util/src/entities/Session.ts | 20 ++++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) (limited to 'util/src/entities/Session.ts') diff --git a/util/src/entities/Session.ts b/util/src/entities/Session.ts index 7cc325f5..ac5313f1 100644 --- a/util/src/entities/Session.ts +++ b/util/src/entities/Session.ts @@ -1,6 +1,8 @@ import { User } from "./User"; import { BaseClass } from "./BaseClass"; import { Column, Entity, JoinColumn, ManyToOne, RelationId } from "typeorm"; +import { Status } from "../interfaces/Status"; +import { Activity } from "../interfaces/Activity"; //TODO we need to remove all sessions on server start because if the server crashes without closing websockets it won't delete them @@ -17,11 +19,13 @@ export class Session extends BaseClass { user: User; //TODO check, should be 32 char long hex string - @Column({ nullable: false }) + @Column({ nullable: false, select: false }) session_id: string; - activities: []; //TODO + @Column({ type: "simple-json", nullable: true }) + activities: Activity[] = []; + // TODO client_status @Column({ type: "simple-json", select: false }) client_info: { client: string; @@ -29,6 +33,14 @@ export class Session extends BaseClass { version: number; }; - @Column({ nullable: false }) - status: string; //TODO enum + @Column({ nullable: false, type: "varchar" }) + status: Status; //TODO enum } + +export const PrivateSessionProjection: (keyof Session)[] = [ + "user_id", + "session_id", + "activities", + "client_info", + "status", +]; -- cgit 1.5.1 From 9fa1081803bb4e0cc043cd554b8c1d67f7ae5e68 Mon Sep 17 00:00:00 2001 From: Flam3rboy <34555296+Flam3rboy@users.noreply.github.com> Date: Sun, 17 Oct 2021 00:57:31 +0200 Subject: :bug: default session activites --- gateway/src/opcodes/Identify.ts | 1 + util/src/entities/Session.ts | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) (limited to 'util/src/entities/Session.ts') diff --git a/gateway/src/opcodes/Identify.ts b/gateway/src/opcodes/Identify.ts index bd7fc894..f39ac808 100644 --- a/gateway/src/opcodes/Identify.ts +++ b/gateway/src/opcodes/Identify.ts @@ -94,6 +94,7 @@ export async function onIdentify(this: WebSocket, data: Payload) { os: identify.properties?.os, version: 0, }, + activities: [], }).save(), Application.findOne({ id: this.user_id }), ]); diff --git a/util/src/entities/Session.ts b/util/src/entities/Session.ts index ac5313f1..969efa89 100644 --- a/util/src/entities/Session.ts +++ b/util/src/entities/Session.ts @@ -23,7 +23,7 @@ export class Session extends BaseClass { session_id: string; @Column({ type: "simple-json", nullable: true }) - activities: Activity[] = []; + activities: Activity[]; // TODO client_status @Column({ type: "simple-json", select: false }) -- cgit 1.5.1