From 7cd39acbf697e3055201b5a8d8ec03129fbeba5b Mon Sep 17 00:00:00 2001 From: MathMan05 Date: Tue, 9 Dec 2025 15:57:02 -0600 Subject: [PATCH] wss on voice conditionally --- src/webpage/localuser.ts | 14 +++++++++----- src/webpage/voice.ts | 7 ++++++- 2 files changed, 15 insertions(+), 6 deletions(-) diff --git a/src/webpage/localuser.ts b/src/webpage/localuser.ts index 32a2a0b..c6348dc 100644 --- a/src/webpage/localuser.ts +++ b/src/webpage/localuser.ts @@ -322,11 +322,15 @@ class Localuser { this.mdBox(); - this.voiceFactory = new VoiceFactory({id: this.user.id}, (g) => { - if (this.ws) { - this.ws.send(JSON.stringify(g)); - } - }); + this.voiceFactory = new VoiceFactory( + {id: this.user.id}, + (g) => { + if (this.ws) { + this.ws.send(JSON.stringify(g)); + } + }, + this.info.api.startsWith("https://"), + ); this.handleVoice(); this.mfa_enabled = ready.d.user.mfa_enabled as boolean; this.userinfo.username = this.user.username; diff --git a/src/webpage/voice.ts b/src/webpage/voice.ts index 15c8d92..0c293db 100644 --- a/src/webpage/voice.ts +++ b/src/webpage/voice.ts @@ -15,10 +15,13 @@ function forceVideo(video: HTMLVideoElement) { class VoiceFactory { settings: {id: string}; handleGateway: (obj: Object) => void; + secure: boolean; constructor( usersettings: VoiceFactory["settings"], handleGateway: VoiceFactory["handleGateway"], + secure: boolean, ) { + this.secure = secure; this.settings = usersettings; this.handleGateway = handleGateway; } @@ -1312,7 +1315,9 @@ a=rtcp-mux\r`; } } - const ws = new WebSocket(("wss://" + this.urlobj.url) as string); + const ws = new WebSocket( + ((this.owner.secure ? "wss://" : "ws://") + this.urlobj.url) as string, + ); this.ws = ws; ws.onclose = () => { this.leave();