From 4cac4584f391c0b1c02a4bb7c11990fa8c33261a Mon Sep 17 00:00:00 2001 From: WarmUpTill <19472752+WarmUpTill@users.noreply.github.com> Date: Wed, 20 Aug 2025 21:04:00 +0200 Subject: [PATCH] Fix invalid channel selections leading to event sub disconnect Repeated invalid POSTs to /helix/eventsub/subscriptions will lead to a disconnect of the event sub websocket connection. Thus one single invalid channel selection could tear down any existing subscriptions with it. --- plugins/twitch/channel-selection.cpp | 2 +- plugins/twitch/channel-selection.hpp | 2 +- plugins/twitch/macro-condition-twitch.cpp | 7 +++++++ 3 files changed, 9 insertions(+), 2 deletions(-) diff --git a/plugins/twitch/channel-selection.cpp b/plugins/twitch/channel-selection.cpp index 6d9f3187..745cbee5 100644 --- a/plugins/twitch/channel-selection.cpp +++ b/plugins/twitch/channel-selection.cpp @@ -197,7 +197,7 @@ void TwitchChannel::ResolveVariables() _name.ResolveVariables(); } -bool TwitchChannel::IsValid(const std::string &id) const +bool TwitchChannel::IsValid(const std::string &id) { return id != "invalid" && !id.empty(); } diff --git a/plugins/twitch/channel-selection.hpp b/plugins/twitch/channel-selection.hpp index 0a554eb3..1e2efc24 100644 --- a/plugins/twitch/channel-selection.hpp +++ b/plugins/twitch/channel-selection.hpp @@ -51,7 +51,7 @@ struct TwitchChannel { void SetName(const StringVariable &name) { _name = name; } StringVariable GetName() const { return _name; } std::string GetUserID(const TwitchToken &token) const; - bool IsValid(const std::string &id) const; + static bool IsValid(const std::string &id); std::optional GetLiveInfo(const TwitchToken &) const; std::optional GetInfo(const TwitchToken &) const; void ResolveVariables(); diff --git a/plugins/twitch/macro-condition-twitch.cpp b/plugins/twitch/macro-condition-twitch.cpp index 13df1d8d..49530aa9 100644 --- a/plugins/twitch/macro-condition-twitch.cpp +++ b/plugins/twitch/macro-condition-twitch.cpp @@ -1096,6 +1096,13 @@ void MacroConditionTwitch::AddChannelGenericEventSubscription( return; } + const auto channelID = _channel.GetUserID(*token); + if (!TwitchChannel::IsValid(channelID)) { + vblog(LOG_INFO, "skip %s because of invalid channel selection", + __func__); + return; + } + OBSDataAutoRelease temp = obs_data_create(); Subscription subscription{temp.Get()}; obs_data_set_string(subscription.data, "type",