summary refs log tree commit diff
path: root/src/gateway/opcodes
diff options
context:
space:
mode:
authorTheArcaneBrony <myrainbowdash949@gmail.com>2022-08-15 11:13:21 +0200
committerTheArcaneBrony <myrainbowdash949@gmail.com>2022-08-15 11:13:21 +0200
commit1a94fb1208bf0e4c669cad16aff5f57dc0bf7a3c (patch)
tree1035116ddbaacc5fcc5ae250a6592eb88f78f75c /src/gateway/opcodes
parentDo the funny thing (make user->invite cascade delet) (diff)
parentchange dev panel path, we missed this one... (diff)
downloadserver-1a94fb1208bf0e4c669cad16aff5f57dc0bf7a3c.tar.xz
Merge branch 'dev/restructure' into staging
Diffstat (limited to '')
-rw-r--r--src/gateway/opcodes/Heartbeat.ts (renamed from gateway/src/opcodes/Heartbeat.ts)0
-rw-r--r--src/gateway/opcodes/Identify.ts (renamed from gateway/src/opcodes/Identify.ts)12
-rw-r--r--src/gateway/opcodes/LazyRequest.ts (renamed from gateway/src/opcodes/LazyRequest.ts)5
-rw-r--r--src/gateway/opcodes/PresenceUpdate.ts (renamed from gateway/src/opcodes/PresenceUpdate.ts)3
-rw-r--r--src/gateway/opcodes/RequestGuildMembers.ts (renamed from gateway/src/opcodes/RequestGuildMembers.ts)0
-rw-r--r--src/gateway/opcodes/Resume.ts (renamed from gateway/src/opcodes/Resume.ts)0
-rw-r--r--src/gateway/opcodes/VoiceStateUpdate.ts (renamed from gateway/src/opcodes/VoiceStateUpdate.ts)9
-rw-r--r--src/gateway/opcodes/experiments.json (renamed from gateway/src/opcodes/experiments.json)0
-rw-r--r--src/gateway/opcodes/index.ts (renamed from gateway/src/opcodes/index.ts)0
-rw-r--r--src/gateway/opcodes/instanceOf.ts (renamed from gateway/src/opcodes/instanceOf.ts)0
10 files changed, 19 insertions, 10 deletions
diff --git a/gateway/src/opcodes/Heartbeat.ts b/src/gateway/opcodes/Heartbeat.ts

index 42b72d4b..42b72d4b 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 03fff796..44db598c 100644 --- a/gateway/src/opcodes/Identify.ts +++ b/src/gateway/opcodes/Identify.ts
@@ -18,12 +18,13 @@ import { PrivateSessionProjection, MemberPrivateProjection, PresenceUpdateEvent, + UserSettings, + IdentifySchema, } from "@fosscord/util"; import { Send } from "../util/Send"; import { CLOSECODES, OPCODES } from "../util/Constants"; import { genSessionId } from "../util/SessionUtils"; import { setupListener } from "../listener/listener"; -import { IdentifySchema } from "../schema/Identify"; // import experiments from "./experiments.json"; const experiments: any = []; import { check } from "./instanceOf"; @@ -56,7 +57,7 @@ export async function onIdentify(this: WebSocket, data: Payload) { await Promise.all([ User.findOneOrFail({ where: { id: this.user_id }, - relations: ["relationships", "relationships.to"], + relations: ["relationships", "relationships.to", "settings"], select: [...PrivateUserProjection, "relationships"], }), ReadState.find({ where: { user_id: this.user_id } }), @@ -101,8 +102,13 @@ export async function onIdentify(this: WebSocket, data: Payload) { ]); if (!user) return this.close(CLOSECODES.Authentication_failed); + if (!user.settings) { //settings may not exist after updating... + user.settings = new UserSettings(); + user.settings.id = user.id; + //await (user.settings as UserSettings).save(); + } - if (!identify.intents) identify.intents = BigInt("0x6ffffffff"); + if (!identify.intents) identify.intents = "30064771071"; this.intents = new Intents(identify.intents); if (identify.shard) { this.shard_id = identify.shard[0]; diff --git a/gateway/src/opcodes/LazyRequest.ts b/src/gateway/opcodes/LazyRequest.ts
index 5ba65cdd..74996f5b 100644 --- a/gateway/src/opcodes/LazyRequest.ts +++ b/src/gateway/opcodes/LazyRequest.ts
@@ -1,5 +1,4 @@ -import { getPermission, listenEvent, Member, Role, getOrInitialiseDatabase } from "@fosscord/util"; -import { LazyRequest } from "../schema/LazyRequest"; +import { getPermission, listenEvent, Member, Role, getOrInitialiseDatabase, LazyRequest } from "@fosscord/util"; import { Send } from "../util/Send"; import { OPCODES } from "../util/Constants"; import { WebSocket, Payload, handlePresenceUpdate } from "@fosscord/gateway"; @@ -17,7 +16,7 @@ async function getMembers(guild_id: string, range: [number, number]) { // TODO: wait for typeorm to implement ordering for .find queries https://github.com/typeorm/typeorm/issues/2620 // TODO: rewrite this, released in 0.3.0 - let members = await (await getOrInitialiseDatabase()).getRepository(Member) + let members: Member[] = await (await getOrInitialiseDatabase()).getRepository(Member) .createQueryBuilder("member") .where("member.guild_id = :guild_id", { guild_id }) .leftJoinAndSelect("member.roles", "role") diff --git a/gateway/src/opcodes/PresenceUpdate.ts b/src/gateway/opcodes/PresenceUpdate.ts
index 415df6ee..f31c9161 100644 --- a/gateway/src/opcodes/PresenceUpdate.ts +++ b/src/gateway/opcodes/PresenceUpdate.ts
@@ -1,6 +1,5 @@ import { WebSocket, Payload } from "@fosscord/gateway"; -import { emitEvent, PresenceUpdateEvent, Session, User } from "@fosscord/util"; -import { ActivitySchema } from "../schema/Activity"; +import { ActivitySchema, emitEvent, PresenceUpdateEvent, Session, User } from "@fosscord/util"; import { check } from "./instanceOf"; export async function onPresenceUpdate(this: WebSocket, { d }: Payload) { 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 d62425f3..c4297a68 100644 --- a/gateway/src/opcodes/VoiceStateUpdate.ts +++ b/src/gateway/opcodes/VoiceStateUpdate.ts
@@ -1,4 +1,3 @@ -import { VoiceStateUpdateSchema } from "../schema/VoiceStateUpdateSchema"; import { Payload, WebSocket } from "@fosscord/gateway"; import { genVoiceToken } from "../util/SessionUtils"; import { check } from "./instanceOf"; @@ -7,12 +6,13 @@ import { emitEvent, Guild, Member, - Region, VoiceServerUpdateEvent, VoiceState, VoiceStateUpdateEvent, + VoiceStateUpdateSchema, } from "@fosscord/util"; import { OrmUtils } from "@fosscord/util"; +import { Region } from "@fosscord/util"; // TODO: check if a voice server is setup // Notice: Bot users respect the voice channel's user limit, if set. When the voice channel is full, you will not receive the Voice State Update or Voice Server Update events in response to your own Voice State Update. Having MANAGE_CHANNELS permission bypasses this limit and allows you to join regardless of the channel being full or not. @@ -20,6 +20,11 @@ export async function onVoiceStateUpdate(this: WebSocket, data: Payload) { check.call(this, VoiceStateUpdateSchema, data.d); const body = data.d as VoiceStateUpdateSchema; + if(body.guild_id == null) { + console.log(`[Gateway] VoiceStateUpdate called with guild_id == null by user ${this.user_id}!`); + return; + } + let voiceState: VoiceState; try { voiceState = await VoiceState.findOneOrFail({ 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 eb6f6ea1..eb6f6ea1 100644 --- a/gateway/src/opcodes/instanceOf.ts +++ b/src/gateway/opcodes/instanceOf.ts