Fix highlight mentions not updating when username changes (#6723)

Reported-by: James Upjohn <jupjohn@jammeh.co.nz>
Reviewed-by: pajlada <rasmus.karlsson@pajlada.com>
Reviewed-by: Nerixyz <nerixdev@outlook.de>
This commit is contained in:
SonicSegFault
2026-01-11 23:22:38 +05:30
committed by GitHub
parent a8ac28425f
commit cffd86aa4f
6 changed files with 36 additions and 4 deletions
+14 -4
View File
@@ -10,6 +10,7 @@
#include "common/Literals.hpp"
#include "common/network/NetworkResult.hpp"
#include "common/QLogging.hpp"
#include "controllers/accounts/AccountController.hpp"
#include "messages/MessageBuilder.hpp"
#include "providers/twitch/api/Helix.hpp"
#include "providers/twitch/TwitchAccount.hpp"
@@ -50,13 +51,13 @@ QString missingScopes(const QJsonArray &scopesArray)
return missingList;
}
void checkMissingScopes(const QString &token)
void checkMissingScopes(const std::shared_ptr<TwitchAccount> &account)
{
NetworkRequest(u"https://id.twitch.tv/oauth2/validate"_s,
NetworkRequestType::Get)
.header("Authorization", u"OAuth " % token)
.header("Authorization", u"OAuth " % account->getOAuthToken())
.timeout(20000)
.onSuccess([](const auto &res) {
.onSuccess([account](const auto &res) {
auto *app = tryGetApp();
if (!app)
{
@@ -64,6 +65,15 @@ void checkMissingScopes(const QString &token)
}
const auto json = res.parseJson();
const auto login = json["login"_L1].toString();
if (!login.isEmpty() &&
login.compare(account->getUserName(), Qt::CaseInsensitive) != 0)
{
account->setUserName(login);
app->getAccounts()->twitch.currentUserNameChanged.invoke();
}
auto missing = missingScopes(json["scopes"_L1].toArray());
if (missing.isEmpty())
{
@@ -209,7 +219,7 @@ TwitchAccountManager::TwitchAccountManager()
currentUser->loadSeventvUserID();
if (!currentUser->isAnon())
{
checkMissingScopes(currentUser->getOAuthToken());
checkMissingScopes(currentUser);
}
});