Fix Twitch token being treated as invalid after load with broken config
Some checks failed
debian-build / build (push) Has been cancelled
Push to master / Check Formatting 🔍 (push) Has been cancelled
Push to master / Build Project 🧱 (push) Has been cancelled
Push to master / Create Release 🛫 (push) Has been cancelled

This commit is contained in:
WarmUpTill
2026-09-20 00:14:33 +02:00
committed by WarmUpTill
parent 3b63db2bde
commit abc8c3708f
2 changed files with 10 additions and 2 deletions

View File

@@ -233,7 +233,11 @@ void TwitchToken::Load(obs_data_t *obj)
{
Item::Load(obj);
_token = obs_data_get_string(obj, "token");
_userID = obs_data_get_string(obj, "userID");
if (obs_data_has_user_value(obj, "userID")) {
_userID = obs_data_get_string(obj, "userID");
} else {
_userID = {};
}
obs_data_set_default_bool(obj, "validateEventSubTimestamps", true);
_validateEventSubTimestamps =
obs_data_get_bool(obj, "validateEventSubTimestamps");
@@ -396,6 +400,10 @@ bool TwitchToken::IsValid(bool forceUpdate) const
return false;
}
if (!_userID) {
_userID = id;
}
_lastValidityCheckResult = true;
return true;
};

View File

@@ -65,7 +65,7 @@ private:
mutable std::string _lastValidityCheckValue;
mutable bool _lastValidityCheckResult = false;
mutable std::chrono::system_clock::time_point _lastValidityCheckTime;
std::optional<std::string> _userID;
mutable std::optional<std::string> _userID;
std::set<TokenOption> _tokenOptions = TokenOption::GetAllTokenOptions();
std::shared_ptr<EventSub> _eventSub;
bool _validateEventSubTimestamps = false;