diff --git a/gateway/src/Server.ts b/src/gateway/Server.ts
index 7e1489be..7e1489be 100644
--- a/gateway/src/Server.ts
+++ b/src/gateway/Server.ts
diff --git a/gateway/src/events/Close.ts b/src/gateway/events/Close.ts
index 40d9a6f7..40d9a6f7 100644
--- a/gateway/src/events/Close.ts
+++ b/src/gateway/events/Close.ts
diff --git a/gateway/src/events/Connection.ts b/src/gateway/events/Connection.ts
index bed3cf44..bed3cf44 100644
--- a/gateway/src/events/Connection.ts
+++ b/src/gateway/events/Connection.ts
diff --git a/gateway/src/events/Message.ts b/src/gateway/events/Message.ts
index b72ffa37..db7dbad2 100644
--- a/gateway/src/events/Message.ts
+++ b/src/gateway/events/Message.ts
@@ -51,22 +51,22 @@ export async function Message(this: WebSocket, buffer: WS.Data) {
return;
}
- const transaction = Sentry.startTransaction({
- op: OPCODES[data.op],
- name: `GATEWAY ${OPCODES[data.op]}`,
- data: {
- ...data.d,
- token: data?.d?.token ? "[Redacted]" : undefined,
- },
- });
+ // const transaction = Sentry.startTransaction({
+ // op: OPCODES[data.op],
+ // name: `GATEWAY ${OPCODES[data.op]}`,
+ // data: {
+ // ...data.d,
+ // token: data?.d?.token ? "[Redacted]" : undefined,
+ // },
+ // });
try {
var ret = await OPCodeHandler.call(this, data);
- transaction.finish();
+ // transaction.finish();
return ret;
} catch (error) {
Sentry.captureException(error);
- transaction.finish();
+ // transaction.finish();
console.error(`Error: Op ${data.op}`, error);
// if (!this.CLOSED && this.CLOSING)
return this.close(CLOSECODES.Unknown_error);
diff --git a/gateway/src/index.ts b/src/gateway/index.ts
index d77ce931..d77ce931 100644
--- a/gateway/src/index.ts
+++ b/src/gateway/index.ts
diff --git a/gateway/src/listener/listener.ts b/src/gateway/listener/listener.ts
index 5975fbb7..72dd9d5b 100644
--- a/gateway/src/listener/listener.ts
+++ b/src/gateway/listener/listener.ts
@@ -51,15 +51,17 @@ export async function setupListener(this: WebSocket) {
relations: ["channel"],
}),
Relationship.find({
- from_id: this.user_id,
- type: RelationshipType.friends,
+ where: {
+ from_id: this.user_id,
+ type: RelationshipType.friends,
+ }
}),
]);
const guilds = members.map((x) => x.guild);
const dm_channels = recipients.map((x) => x.channel);
- const opts: { acknowledge: boolean; channel?: AMQChannel } = {
+ const opts: { acknowledge: boolean; channel?: AMQChannel; } = {
acknowledge: true,
};
this.listen_options = opts;
diff --git a/gateway/src/opcodes/Heartbeat.ts b/src/gateway/opcodes/Heartbeat.ts
index 50394130..50394130 100644
--- a/gateway/src/opcodes/Heartbeat.ts
+++ b/src/gateway/opcodes/Heartbeat.ts
diff --git a/gateway/src/opcodes/Identify.ts b/src/gateway/opcodes/Identify.ts
index 903934ce..3c40962c 100644
--- a/gateway/src/opcodes/Identify.ts
+++ b/src/gateway/opcodes/Identify.ts
@@ -62,7 +62,7 @@ export async function onIdentify(this: WebSocket, data: Payload) {
relations: ["relationships", "relationships.to"],
select: [...PrivateUserProjection, "relationships"],
}),
- ReadState.find({ user_id: this.user_id }),
+ ReadState.find({ where: { user_id: this.user_id } }),
Member.find({
where: { id: this.user_id },
select: MemberPrivateProjection,
@@ -87,7 +87,7 @@ export async function onIdentify(this: WebSocket, data: Payload) {
// TODO: public user selection
}),
// save the session and delete it when the websocket is closed
- new Session({
+ Session.create({
user_id: this.user_id,
session_id: session_id,
// TODO: check if status is only one of: online, dnd, offline, idle
@@ -100,7 +100,7 @@ export async function onIdentify(this: WebSocket, data: Payload) {
},
activities: [],
}).save(),
- Application.findOne({ id: this.user_id }),
+ Application.findOne({ where: { id: this.user_id } }),
]);
if (!user) return this.close(CLOSECODES.Authentication_failed);
diff --git a/gateway/src/opcodes/LazyRequest.ts b/src/gateway/opcodes/LazyRequest.ts
index b0332969..82342224 100644
--- a/gateway/src/opcodes/LazyRequest.ts
+++ b/src/gateway/opcodes/LazyRequest.ts
@@ -1,12 +1,7 @@
-import { getPermission, listenEvent, Member, Role, Session } from "@fosscord/util";
+import { getDatabase, getPermission, listenEvent, Member, Role, Session } from "@fosscord/util";
+import { WebSocket, Payload, handlePresenceUpdate, OPCODES, Send } from "@fosscord/gateway";
import { LazyRequest } from "../schema/LazyRequest";
-import { Send } from "../util/Send";
-import { OPCODES } from "../util/Constants";
-import { WebSocket, Payload, handlePresenceUpdate } from "@fosscord/gateway";
import { check } from "./instanceOf";
-import "missing-native-js-functions";
-import { getRepository } from "typeorm";
-import "missing-native-js-functions";
// TODO: only show roles/members that have access to this channel
// TODO: config: to list all members (even those who are offline) sorted by role, or just those who are online
@@ -20,7 +15,7 @@ async function getMembers(guild_id: string, range: [number, number]) {
let members: Member[] = [];
try {
- members = await getRepository(Member)
+ members = await getDatabase()!.getRepository(Member)
.createQueryBuilder("member")
.where("member.guild_id = :guild_id", { guild_id })
.leftJoinAndSelect("member.roles", "role")
@@ -34,8 +29,8 @@ async function getMembers(guild_id: string, range: [number, number]) {
.orderBy("role.position", "DESC")
.addOrderBy("_status", "DESC")
.addOrderBy("user.username", "ASC")
- .skip(Number(range[0]) || 0)
- .take(Number(range[1]) || 100)
+ .offset(Number(range[0]) || 0)
+ .limit(Number(range[1]) || 100)
.getMany();
}
catch (e) {
diff --git a/gateway/src/opcodes/PresenceUpdate.ts b/src/gateway/opcodes/PresenceUpdate.ts
index 415df6ee..415df6ee 100644
--- a/gateway/src/opcodes/PresenceUpdate.ts
+++ b/src/gateway/opcodes/PresenceUpdate.ts
diff --git a/gateway/src/opcodes/RequestGuildMembers.ts b/src/gateway/opcodes/RequestGuildMembers.ts
index b80721dc..b80721dc 100644
--- a/gateway/src/opcodes/RequestGuildMembers.ts
+++ b/src/gateway/opcodes/RequestGuildMembers.ts
diff --git a/gateway/src/opcodes/Resume.ts b/src/gateway/opcodes/Resume.ts
index 42dc586d..42dc586d 100644
--- a/gateway/src/opcodes/Resume.ts
+++ b/src/gateway/opcodes/Resume.ts
diff --git a/gateway/src/opcodes/VoiceStateUpdate.ts b/src/gateway/opcodes/VoiceStateUpdate.ts
index ec4b1a92..fa63f7fc 100644
--- a/gateway/src/opcodes/VoiceStateUpdate.ts
+++ b/src/gateway/opcodes/VoiceStateUpdate.ts
@@ -49,7 +49,7 @@ export async function onVoiceStateUpdate(this: WebSocket, data: Payload) {
if (body.guild_id === null) body.guild_id = voiceState.guild_id;
voiceState.assign(body);
} catch (error) {
- voiceState = new VoiceState({
+ voiceState = VoiceState.create({
...body,
user_id: this.user_id,
deaf: false,
@@ -68,7 +68,7 @@ export async function onVoiceStateUpdate(this: WebSocket, data: Payload) {
where: { id: voiceState.user_id, guild_id: voiceState.guild_id },
relations: ["user", "roles"],
});
-
+
//If the session changed we generate a new token
if (voiceState.session_id !== this.session_id)
voiceState.token = genVoiceToken();
@@ -87,7 +87,7 @@ export async function onVoiceStateUpdate(this: WebSocket, data: Payload) {
//If it's null it means that we are leaving the channel and this event is not needed
if (voiceState.channel_id !== null) {
- const guild = await Guild.findOne({ id: voiceState.guild_id });
+ const guild = await Guild.findOne({ where: { id: voiceState.guild_id } });
const regions = Config.get().regions;
let guildRegion: Region;
if (guild && guild.region) {
diff --git a/gateway/src/opcodes/experiments.json b/src/gateway/opcodes/experiments.json
index 0370b5da..0370b5da 100644
--- a/gateway/src/opcodes/experiments.json
+++ b/src/gateway/opcodes/experiments.json
diff --git a/gateway/src/opcodes/index.ts b/src/gateway/opcodes/index.ts
index 027739db..027739db 100644
--- a/gateway/src/opcodes/index.ts
+++ b/src/gateway/opcodes/index.ts
diff --git a/gateway/src/opcodes/instanceOf.ts b/src/gateway/opcodes/instanceOf.ts
index 6fd50852..6fd50852 100644
--- a/gateway/src/opcodes/instanceOf.ts
+++ b/src/gateway/opcodes/instanceOf.ts
diff --git a/gateway/src/schema/Activity.ts b/src/gateway/schema/Activity.ts
index f58b0fa9..f58b0fa9 100644
--- a/gateway/src/schema/Activity.ts
+++ b/src/gateway/schema/Activity.ts
diff --git a/gateway/src/schema/Identify.ts b/src/gateway/schema/Identify.ts
index 6f68b515..6f68b515 100644
--- a/gateway/src/schema/Identify.ts
+++ b/src/gateway/schema/Identify.ts
diff --git a/gateway/src/schema/LazyRequest.ts b/src/gateway/schema/LazyRequest.ts
index 1fe658bb..1fe658bb 100644
--- a/gateway/src/schema/LazyRequest.ts
+++ b/src/gateway/schema/LazyRequest.ts
diff --git a/gateway/src/schema/VoiceStateUpdateSchema.ts b/src/gateway/schema/VoiceStateUpdateSchema.ts
index f6480414..f6480414 100644
--- a/gateway/src/schema/VoiceStateUpdateSchema.ts
+++ b/src/gateway/schema/VoiceStateUpdateSchema.ts
diff --git a/gateway/src/start.ts b/src/gateway/start.ts
index 09a54751..90d7f34e 100644
--- a/gateway/src/start.ts
+++ b/src/gateway/start.ts
@@ -1,3 +1,4 @@
+require('module-alias/register');
process.on("uncaughtException", console.error);
process.on("unhandledRejection", console.error);
diff --git a/gateway/src/util/Constants.ts b/src/gateway/util/Constants.ts
index ff9b5525..ff9b5525 100644
--- a/gateway/src/util/Constants.ts
+++ b/src/gateway/util/Constants.ts
diff --git a/gateway/src/util/Heartbeat.ts b/src/gateway/util/Heartbeat.ts
index f6871cfe..f6871cfe 100644
--- a/gateway/src/util/Heartbeat.ts
+++ b/src/gateway/util/Heartbeat.ts
diff --git a/gateway/src/util/Send.ts b/src/gateway/util/Send.ts
index e1460846..e1460846 100644
--- a/gateway/src/util/Send.ts
+++ b/src/gateway/util/Send.ts
diff --git a/gateway/src/util/SessionUtils.ts b/src/gateway/util/SessionUtils.ts
index bf854042..bf854042 100644
--- a/gateway/src/util/SessionUtils.ts
+++ b/src/gateway/util/SessionUtils.ts
diff --git a/gateway/src/util/WebSocket.ts b/src/gateway/util/WebSocket.ts
index 930fa78a..930fa78a 100644
--- a/gateway/src/util/WebSocket.ts
+++ b/src/gateway/util/WebSocket.ts
diff --git a/gateway/src/util/index.ts b/src/gateway/util/index.ts
index 0be5ecee..0be5ecee 100644
--- a/gateway/src/util/index.ts
+++ b/src/gateway/util/index.ts
|