From 20dd232a705fe16225ee97250883578b7afd2213 Mon Sep 17 00:00:00 2001 From: Samuel Elliott Date: Sun, 18 Dec 2022 13:16:48 +0000 Subject: [PATCH] Disable automatic upgrade to presence event streams by default --- src/common/presence.ts | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/common/presence.ts b/src/common/presence.ts index 62452a5..aedcb21 100644 --- a/src/common/presence.ts +++ b/src/common/presence.ts @@ -510,6 +510,7 @@ export class ZncProxyDiscordPresence extends Loop { readonly user_notifications = false; readonly friend_notifications = false; update_interval = 30; + upgrade_to_sse = process.env.NXAPI_PRESENCE_SSE === '1'; presence_user: null = null; discord_preconnect = false; @@ -565,7 +566,7 @@ export class ZncProxyDiscordPresence extends Loop { debug('presence links', links); const eventstream_link = links.find(l => l.rel.includes('alternate') && l.type === 'text/event-stream'); - if (eventstream_link) { + if (eventstream_link && this.upgrade_to_sse) { this.eventstream_url = new URL(eventstream_link.uri, this.presence_url).href; this.is_sse = true; debug('Presence URL included server-sent events link, switching now', this.eventstream_url); @@ -574,7 +575,7 @@ export class ZncProxyDiscordPresence extends Loop { this.is_first_request = false; // Connect to the event stream immediately - if (eventstream_link) return LoopResult.OK_SKIP_INTERVAL; + if (this.is_sse) return LoopResult.OK_SKIP_INTERVAL; } } catch (err) { if (err instanceof ErrorResponse) {