From 2c7b14bc37e5b118ac75460642d5d3a2288cbe29 Mon Sep 17 00:00:00 2001 From: derrod Date: Fri, 3 Dec 2021 19:45:54 +0100 Subject: [PATCH] UI: Add UUID to Twitch panel URLs Some Twitch dashboard panels now require a UUID, it is not used for anything but local storage right now, and according to Twitch we can generate it ourselves (or even use a static string). To be safe we can just use QUuid to generate a "real" UUID and then store it locally until the user disconnects the account. --- UI/auth-twitch.cpp | 16 ++++++++++++++++ UI/auth-twitch.hpp | 1 + 2 files changed, 17 insertions(+) diff --git a/UI/auth-twitch.cpp b/UI/auth-twitch.cpp index 30c9bcaf4..d9f5bbdab 100644 --- a/UI/auth-twitch.cpp +++ b/UI/auth-twitch.cpp @@ -1,8 +1,10 @@ #include "auth-twitch.hpp" +#include #include #include #include +#include #include #include @@ -146,6 +148,8 @@ void TwitchAuth::SaveInternal() { OBSBasic *main = OBSBasic::Get(); config_set_string(main->Config(), service(), "Name", name.c_str()); + config_set_string(main->Config(), service(), "UUID", uuid.c_str()); + if (uiLoaded) { config_set_string(main->Config(), service(), "DockState", main->saveState().toBase64().constData()); @@ -167,6 +171,8 @@ bool TwitchAuth::LoadInternal() OBSBasic *main = OBSBasic::Get(); name = get_config_str(main, service(), "Name"); + uuid = get_config_str(main, service(), "UUID"); + firstLoad = false; return OAuthStreamKey::LoadInternal(); } @@ -204,6 +210,15 @@ void TwitchAuth::LoadUI() std::string url; std::string script; + /* Twitch panels require a UUID, it does not actually need to be unique, + * and is generated client-side. + * It is only for preferences stored in the browser's local store. */ + if (uuid.empty()) { + QString qtUuid = QUuid::createUuid().toString(); + qtUuid.replace(QRegularExpression("[{}-]"), ""); + uuid = qtUuid.toStdString(); + } + std::string moderation_tools_url; moderation_tools_url = "https://www.twitch.tv/"; moderation_tools_url += name; @@ -345,6 +360,7 @@ void TwitchAuth::LoadSecondaryUIPanes() url = "https://dashboard.twitch.tv/popout/u/"; url += name; url += "/stream-manager/activity-feed"; + url += "?uuid=" + uuid; feed.reset(new BrowserDock()); feed->setObjectName("twitchFeed"); diff --git a/UI/auth-twitch.hpp b/UI/auth-twitch.hpp index e9dd2e45e..add9ce57a 100644 --- a/UI/auth-twitch.hpp +++ b/UI/auth-twitch.hpp @@ -26,6 +26,7 @@ class TwitchAuth : public OAuthStreamKey { bool uiLoaded = false; std::string name; + std::string uuid; virtual bool RetryLogin() override;