diff options
Diffstat (limited to 'gateway')
-rw-r--r-- | gateway/package.json | 2 | ||||
-rw-r--r-- | gateway/src/opcodes/Identify.ts | 4 | ||||
-rw-r--r-- | gateway/src/opcodes/LazyRequest.ts | 27 | ||||
-rw-r--r-- | gateway/src/opcodes/VoiceStateUpdate.ts | 5 | ||||
-rw-r--r-- | gateway/src/schema/Identify.ts | 6 |
5 files changed, 35 insertions, 9 deletions
diff --git a/gateway/package.json b/gateway/package.json index 92d812b4..7a3b1012 100644 --- a/gateway/package.json +++ b/gateway/package.json @@ -13,7 +13,7 @@ }, "keywords": [], "author": "Fosscord", - "license": "AGPLV3", + "license": "AGPL-3.0-only", "devDependencies": { "@types/amqplib": "^0.8.1", "@types/jsonwebtoken": "^8.5.0", diff --git a/gateway/src/opcodes/Identify.ts b/gateway/src/opcodes/Identify.ts index 4b617fdd..301f714d 100644 --- a/gateway/src/opcodes/Identify.ts +++ b/gateway/src/opcodes/Identify.ts @@ -34,9 +34,9 @@ import { Recipient } from "@fosscord/util"; // TODO: check if already identified export async function onIdentify(this: WebSocket, data: Payload) { - console.log(data); - clearTimeout(this.readyTimeout); + if (typeof data.d?.client_state?.highest_last_message_id === "number") + data.d.client_state.highest_last_message_id += ""; check.call(this, IdentifySchema, data.d); const identify: IdentifySchema = data.d; diff --git a/gateway/src/opcodes/LazyRequest.ts b/gateway/src/opcodes/LazyRequest.ts index 2156070f..7503ee61 100644 --- a/gateway/src/opcodes/LazyRequest.ts +++ b/gateway/src/opcodes/LazyRequest.ts @@ -42,6 +42,8 @@ async function getMembers(guild_id: string, range: [number, number]) { .flat() .unique((r: Role) => r.id); + const offlineItems = []; + for (const role of member_roles) { // @ts-ignore const [role_members, other_members] = partition(members, (m: Member) => @@ -63,7 +65,7 @@ async function getMembers(guild_id: string, range: [number, number]) { const session = member.user.sessions.first(); // TODO: properly mock/hide offline/invisible status - items.push({ + const item = { member: { ...member, roles, @@ -74,16 +76,35 @@ async function getMembers(guild_id: string, range: [number, number]) { user: { id: member.user.id }, }, }, - }); + } + + if (!member?.user?.sessions || !member.user.sessions.length) { + offlineItems.push(item); + group.count--; + continue; + } + + items.push(item); } members = other_members; } + if (offlineItems.length) { + const group = { + count: offlineItems.length, + id: "offline", + }; + items.push({ group }); + groups.push(group); + + items.push(...offlineItems); + } + return { items, groups, range, - members: items.map((x) => x.member).filter((x) => x), + members: items.map((x) => 'member' in x ? x.member : undefined).filter(x => !!x), }; } diff --git a/gateway/src/opcodes/VoiceStateUpdate.ts b/gateway/src/opcodes/VoiceStateUpdate.ts index 321e6b17..ec4b1a92 100644 --- a/gateway/src/opcodes/VoiceStateUpdate.ts +++ b/gateway/src/opcodes/VoiceStateUpdate.ts @@ -58,6 +58,9 @@ export async function onVoiceStateUpdate(this: WebSocket, data: Payload) { }); } + // 'Fix' for this one voice state error + if (!voiceState.guild_id) return; + //TODO the member should only have these properties: hoisted_role, deaf, joined_at, mute, roles, user //TODO the member.user should only have these properties: avatar, discriminator, id, username //TODO this may fail @@ -65,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(); diff --git a/gateway/src/schema/Identify.ts b/gateway/src/schema/Identify.ts index 21141321..6aa93ce7 100644 --- a/gateway/src/schema/Identify.ts +++ b/gateway/src/schema/Identify.ts @@ -38,10 +38,11 @@ export const IdentifySchema = { $capabilities: Number, $client_state: { $guild_hashes: Object, - $highest_last_message_id: String, + $highest_last_message_id: String || Number, $read_state_version: Number, $user_guild_settings_version: Number, $user_settings_version: undefined, + $useruser_guild_settings_version: Number, }, $v: Number, $version: Number, @@ -80,10 +81,11 @@ export interface IdentifySchema { capabilities?: number; client_state?: { guild_hashes?: any; - highest_last_message_id?: string; + highest_last_message_id?: string | number; read_state_version?: number; user_guild_settings_version?: number; user_settings_version?: number; + useruser_guild_settings_version?: number; }; v?: number; } |