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.
This commit is contained in:
WarmUpTill 2025-08-20 21:04:00 +02:00 committed by WarmUpTill
parent d20a975c4f
commit 4cac4584f3
3 changed files with 9 additions and 2 deletions

View File

@ -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();
}

View File

@ -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<ChannelLiveInfo> GetLiveInfo(const TwitchToken &) const;
std::optional<ChannelInfo> GetInfo(const TwitchToken &) const;
void ResolveVariables();

View File

@ -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",