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.master
parent
2e1c5fc801
commit
2c7b14bc37
|
@ -1,8 +1,10 @@
|
||||||
#include "auth-twitch.hpp"
|
#include "auth-twitch.hpp"
|
||||||
|
|
||||||
|
#include <QRegularExpression>
|
||||||
#include <QPushButton>
|
#include <QPushButton>
|
||||||
#include <QHBoxLayout>
|
#include <QHBoxLayout>
|
||||||
#include <QVBoxLayout>
|
#include <QVBoxLayout>
|
||||||
|
#include <QUuid>
|
||||||
|
|
||||||
#include <qt-wrappers.hpp>
|
#include <qt-wrappers.hpp>
|
||||||
#include <obs-app.hpp>
|
#include <obs-app.hpp>
|
||||||
|
@ -146,6 +148,8 @@ void TwitchAuth::SaveInternal()
|
||||||
{
|
{
|
||||||
OBSBasic *main = OBSBasic::Get();
|
OBSBasic *main = OBSBasic::Get();
|
||||||
config_set_string(main->Config(), service(), "Name", name.c_str());
|
config_set_string(main->Config(), service(), "Name", name.c_str());
|
||||||
|
config_set_string(main->Config(), service(), "UUID", uuid.c_str());
|
||||||
|
|
||||||
if (uiLoaded) {
|
if (uiLoaded) {
|
||||||
config_set_string(main->Config(), service(), "DockState",
|
config_set_string(main->Config(), service(), "DockState",
|
||||||
main->saveState().toBase64().constData());
|
main->saveState().toBase64().constData());
|
||||||
|
@ -167,6 +171,8 @@ bool TwitchAuth::LoadInternal()
|
||||||
|
|
||||||
OBSBasic *main = OBSBasic::Get();
|
OBSBasic *main = OBSBasic::Get();
|
||||||
name = get_config_str(main, service(), "Name");
|
name = get_config_str(main, service(), "Name");
|
||||||
|
uuid = get_config_str(main, service(), "UUID");
|
||||||
|
|
||||||
firstLoad = false;
|
firstLoad = false;
|
||||||
return OAuthStreamKey::LoadInternal();
|
return OAuthStreamKey::LoadInternal();
|
||||||
}
|
}
|
||||||
|
@ -204,6 +210,15 @@ void TwitchAuth::LoadUI()
|
||||||
std::string url;
|
std::string url;
|
||||||
std::string script;
|
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;
|
std::string moderation_tools_url;
|
||||||
moderation_tools_url = "https://www.twitch.tv/";
|
moderation_tools_url = "https://www.twitch.tv/";
|
||||||
moderation_tools_url += name;
|
moderation_tools_url += name;
|
||||||
|
@ -345,6 +360,7 @@ void TwitchAuth::LoadSecondaryUIPanes()
|
||||||
url = "https://dashboard.twitch.tv/popout/u/";
|
url = "https://dashboard.twitch.tv/popout/u/";
|
||||||
url += name;
|
url += name;
|
||||||
url += "/stream-manager/activity-feed";
|
url += "/stream-manager/activity-feed";
|
||||||
|
url += "?uuid=" + uuid;
|
||||||
|
|
||||||
feed.reset(new BrowserDock());
|
feed.reset(new BrowserDock());
|
||||||
feed->setObjectName("twitchFeed");
|
feed->setObjectName("twitchFeed");
|
||||||
|
|
|
@ -26,6 +26,7 @@ class TwitchAuth : public OAuthStreamKey {
|
||||||
bool uiLoaded = false;
|
bool uiLoaded = false;
|
||||||
|
|
||||||
std::string name;
|
std::string name;
|
||||||
|
std::string uuid;
|
||||||
|
|
||||||
virtual bool RetryLogin() override;
|
virtual bool RetryLogin() override;
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue