diff --git a/client.js b/client.js
index ceb97bdd..57b747a6 100644
--- a/client.js
+++ b/client.js
@@ -30,7 +30,8 @@ ws.on("message", (buffer) => {
send({
op: 2,
d: {
- token: "",
+ token:
+ "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpZCI6IjgxMTY0MjkxNzQzMjA2NjA0OCIsImlhdCI6MTYxMzU4MTE1MX0.7Qj_z2lYIgJ0rc7NfGtpW5DKGqecQfv1mLpoBUQHKDc",
intents: 0n,
properties: {},
},
diff --git a/package-lock.json b/package-lock.json
index 3ac15e3c..8ffdc66d 100644
--- a/package-lock.json
+++ b/package-lock.json
@@ -549,7 +549,7 @@
},
"node_modules/fosscord-server-util": {
"version": "1.0.0",
- "resolved": "git+ssh://git@github.com/fosscord/fosscord-server-util.git#2859daeba89e56683c60d99db0d6100fa4ac797d",
+ "resolved": "git+ssh://git@github.com/fosscord/fosscord-server-util.git#64ab9e049ad4d3b68c0b9a9ce2e08363e77d3c84",
"license": "ISC",
"dependencies": {
"jsonwebtoken": "^8.5.1",
@@ -2216,7 +2216,7 @@
"integrity": "sha1-mMI9qxF1ZXuMBXPozszZGw/xjIQ="
},
"fosscord-server-util": {
- "version": "git+ssh://git@github.com/fosscord/fosscord-server-util.git#2859daeba89e56683c60d99db0d6100fa4ac797d",
+ "version": "git+ssh://git@github.com/fosscord/fosscord-server-util.git#64ab9e049ad4d3b68c0b9a9ce2e08363e77d3c84",
"from": "fosscord-server-util@github:fosscord/fosscord-server-util",
"requires": {
"jsonwebtoken": "^8.5.1",
diff --git a/src/Server.ts b/src/Server.ts
index 302aea81..df5ec905 100644
--- a/src/Server.ts
+++ b/src/Server.ts
@@ -1,3 +1,6 @@
+import "missing-native-js-functions";
+import dotenv from "dotenv";
+dotenv.config();
import { db } from "fosscord-server-util";
import { Server as WebSocketServer } from "ws";
import { Connection } from "./events/Connection";
@@ -19,7 +22,8 @@ export class Server {
// @ts-ignore
await (db as Promise<Connection>);
await this.setupSchema();
+ console.log("[DB] connected");
await Config.init();
- console.log("listening");
+ console.log("[Gateway] online");
}
}
diff --git a/src/index.ts b/src/index.ts
index e34ae0d3..2fe360e2 100644
--- a/src/index.ts
+++ b/src/index.ts
@@ -1,6 +1,5 @@
process.on("uncaughtException", console.error);
process.on("unhandledRejection", console.error);
-setTimeout(() => {}, 100000000);
import { Server } from "./Server";
import { config } from "dotenv";
diff --git a/src/listener/listener.ts b/src/listener/listener.ts
index 24b05765..b6ae0ac6 100644
--- a/src/listener/listener.ts
+++ b/src/listener/listener.ts
@@ -8,11 +8,11 @@ import WebSocket from "../util/WebSocket";
// ? How to resubscribe MongooseCache for new dm channel events? Maybe directly send them to the user_id regardless of the channel_id? -> max overhead of creating 10 events in database for dm user group. Or a new field in event -> recipient_ids?
export async function setupListener(this: WebSocket) {
- const user = await UserModel.findOne({ id: this.userid }).exec();
+ const user = await UserModel.findOne({ id: this.user_id }).exec();
const eventStream = new MongooseCache(
db.collection("events"),
- [{ $match: { $or: [{ guild_id: { $in: user.guilds } }, { user_id: this.userid }] } }],
+ [{ $match: { $or: [{ guild_id: { $in: user.guilds } }, { user_id: this.user_id }] } }],
{ onlyEvents: true }
);
await eventStream.init();
@@ -27,7 +27,7 @@ export async function dispatch(this: WebSocket, document: Event) {
if (document.guild_id) {
if (!this.intents.has("GUILDS")) return;
const channel_id = document.channel_id || document.data?.channel_id;
- permission = await getPermission(this.userid, document.guild_id, channel_id);
+ permission = await getPermission(this.user_id, document.guild_id, channel_id);
}
console.log("event", document);
diff --git a/src/opcodes/Identify.ts b/src/opcodes/Identify.ts
index f62f66b0..f2542bc8 100644
--- a/src/opcodes/Identify.ts
+++ b/src/opcodes/Identify.ts
@@ -14,7 +14,7 @@ export async function onIdentify(this: WebSocket, data: Payload) {
const identify: IdentifySchema = data.d;
var decoded = await checkToken(identify.token);
- this.userid = decoded.id;
+ this.user_id = decoded.id;
this.intents = new Intents(identify.intents);
await setupListener.call(this);
diff --git a/src/util/WebSocket.ts b/src/util/WebSocket.ts
index 10b8348f..5d107d9c 100644
--- a/src/util/WebSocket.ts
+++ b/src/util/WebSocket.ts
@@ -3,7 +3,7 @@ import WS, { Server, Data } from "ws";
interface WebSocket extends WS {
version: number;
- userid: bigint;
+ user_id: bigint;
encoding: "etf" | "json";
compress?: "zlib-stream";
heartbeatTimeout: NodeJS.Timeout;
|