summary refs log tree commit diff
path: root/src/gateway/opcodes/StreamCreate.ts
diff options
context:
space:
mode:
authorRory& <root@rory.gay>2025-12-17 09:23:55 +0100
committerRory& <root@rory.gay>2025-12-17 09:23:55 +0100
commit45ee84aca9c19be58fe487157ba93d6e38ccd8f8 (patch)
treef72f44caf4028729121c6737b378c5b4d8ea6709 /src/gateway/opcodes/StreamCreate.ts
parentPrettier u7 (diff)
downloadserver-ts-45ee84aca9c19be58fe487157ba93d6e38ccd8f8.tar.xz
Prettier u8
Diffstat (limited to 'src/gateway/opcodes/StreamCreate.ts')
-rw-r--r--src/gateway/opcodes/StreamCreate.ts30
1 files changed, 6 insertions, 24 deletions
diff --git a/src/gateway/opcodes/StreamCreate.ts b/src/gateway/opcodes/StreamCreate.ts

index 3defc123..00c8c947 100644 --- a/src/gateway/opcodes/StreamCreate.ts +++ b/src/gateway/opcodes/StreamCreate.ts
@@ -1,9 +1,4 @@ -import { - genVoiceToken, - Payload, - WebSocket, - generateStreamKey, -} from "@spacebar/gateway"; +import { genVoiceToken, Payload, WebSocket, generateStreamKey } from "@spacebar/gateway"; import { Channel, Config, @@ -18,7 +13,7 @@ import { VoiceStateUpdateEvent, } from "@spacebar/util"; import { check } from "./instanceOf"; -import { StreamCreateSchema } from "@spacebar/schemas" +import { StreamCreateSchema } from "@spacebar/schemas"; export async function onStreamCreate(this: WebSocket, data: Payload) { const startTime = Date.now(); @@ -47,17 +42,11 @@ export async function onStreamCreate(this: WebSocket, data: Payload) { where: { id: body.channel_id }, }); - if ( - !channel || - (body.type === "guild" && channel.guild_id != body.guild_id) - ) - return this.close(4000, "invalid channel"); + if (!channel || (body.type === "guild" && channel.guild_id != body.guild_id)) return this.close(4000, "invalid channel"); // TODO: actually apply preferred_region from the event payload const regions = Config.get().regions; - const guildRegion = regions.available.filter( - (r) => r.id === regions.default, - )[0]; + const guildRegion = regions.available.filter((r) => r.id === regions.default)[0]; // first make sure theres no other streams for this user that somehow didnt get cleared await Stream.delete({ @@ -85,12 +74,7 @@ export async function onStreamCreate(this: WebSocket, data: Payload) { await streamSession.save(); - const streamKey = generateStreamKey( - body.type, - body.guild_id, - body.channel_id, - this.user_id, - ); + const streamKey = generateStreamKey(body.type, body.guild_id, body.channel_id, this.user_id); await emitEvent({ event: "STREAM_CREATE", @@ -125,9 +109,7 @@ export async function onStreamCreate(this: WebSocket, data: Payload) { channel_id: voiceState.channel_id, } as VoiceStateUpdateEvent); - console.log( - `[Gateway] STREAM_CREATE for user ${this.user_id} in channel ${body.channel_id} with stream key ${streamKey} in ${Date.now() - startTime}ms`, - ); + console.log(`[Gateway] STREAM_CREATE for user ${this.user_id} in channel ${body.channel_id} with stream key ${streamKey} in ${Date.now() - startTime}ms`); } //stream key: