summary refs log tree commit diff
path: root/gateway
diff options
context:
space:
mode:
authorFlam3rboy <34555296+Flam3rboy@users.noreply.github.com>2021-10-09 17:33:28 +0200
committerFlam3rboy <34555296+Flam3rboy@users.noreply.github.com>2021-10-09 17:33:28 +0200
commitd6bc17a8c7813ba860de0aa554297798f989de0f (patch)
tree8c5d5e54e7a192a1ba74bbb2af1f6d979db52040 /gateway
parent:sparkles: handleFile() now returns mime_type and size (diff)
downloadserver-d6bc17a8c7813ba860de0aa554297798f989de0f.tar.xz
:sparkles: added read state
Diffstat (limited to 'gateway')
-rw-r--r--gateway/src/opcodes/Identify.ts11
1 files changed, 9 insertions, 2 deletions
diff --git a/gateway/src/opcodes/Identify.ts b/gateway/src/opcodes/Identify.ts
index 6decf21c..b81c7bf4 100644
--- a/gateway/src/opcodes/Identify.ts
+++ b/gateway/src/opcodes/Identify.ts
@@ -11,6 +11,7 @@ import {
 	PublicMember,
 	PublicUser,
 	PrivateUserProjection,
+	ReadState,
 } from "@fosscord/util";
 import { Send } from "../util/Send";
 import { CLOSECODES, OPCODES } from "../util/Constants";
@@ -138,6 +139,13 @@ export async function onIdentify(this: WebSocket, data: Payload) {
 	//We save the session and we delete it when the websocket is closed
 	await session.save();
 
+	const read_states = await ReadState.find({ user_id: this.user_id });
+	read_states.forEach((s: any) => {
+		s.id = s.channel_id;
+		delete s.user_id;
+		delete s.channel_id;
+	});
+
 	const privateUser = {
 		avatar: user.avatar,
 		mobile: user.mobile,
@@ -176,8 +184,7 @@ export async function onIdentify(this: WebSocket, data: Payload) {
 		geo_ordered_rtc_regions: [], // TODO
 		relationships: user.relationships.map((x) => x.toPublicRelationship()),
 		read_state: {
-			// TODO
-			entries: [],
+			entries: read_states,
 			partial: false,
 			version: 304128,
 		},