summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorErik Kundiman <erik@megapahit.org>2025-07-30 12:48:44 +0800
committerErik Kundiman <erik@megapahit.org>2025-07-30 12:48:44 +0800
commit275bc9d0e373c8018167c8f4b0ac79e8b782d0ec (patch)
tree2f0055d951f3e5fd30870bc71520d2e3f3712358
parent19cf8ae0b0f2fe9a41331c635228c9454b604206 (diff)
Discord-related error handling/logging
plus delay saving Discord credentials to only after the access token is successfully updated on Discord, and try to disconnect from Discord when the integration gets disabled regardless whether there are credentials to delete or not and whether there's an access token to revoke or not.
-rw-r--r--indra/newview/llappviewer.cpp50
1 files changed, 38 insertions, 12 deletions
diff --git a/indra/newview/llappviewer.cpp b/indra/newview/llappviewer.cpp
index de9d380f30..f65b6f309b 100644
--- a/indra/newview/llappviewer.cpp
+++ b/indra/newview/llappviewer.cpp
@@ -5942,8 +5942,15 @@ void LLAppViewer::initDiscordSocial()
gDiscordClient->UpdateToken(discordpp::AuthorizationTokenType::Bearer, credential->getAuthenticator()["token"].asString(), [](discordpp::ClientResult result) {
if (result.Successful())
gDiscordClient->Connect();
+ else
+ LL_WARNS("Discord") << result.Error() << LL_ENDL;
});
}
+ else
+ {
+ LL_WARNS("Discord") << "Integration was enabled, but no credentials. Disabling integration." << LL_ENDL;
+ gSavedSettings.setBOOL("EnableDiscord", false);
+ }
}
}
@@ -5961,34 +5968,53 @@ void LLAppViewer::handleDiscordSocial(const LLSD& value)
if (result.Successful())
{
gDiscordClient->GetToken(APPLICATION_ID, code, codeVerifier.Verifier(), redirectUri, [](discordpp::ClientResult result, std::string accessToken, std::string, discordpp::AuthorizationTokenType, int32_t, std::string) {
- gDiscordClient->UpdateToken(discordpp::AuthorizationTokenType::Bearer, accessToken, [](discordpp::ClientResult result) {
- if (result.Successful())
- gDiscordClient->Connect();
- });
- LLSD authenticator = LLSD::emptyMap();
- authenticator["token"] = accessToken;
- gSecAPIHandler->saveCredential(gSecAPIHandler->createCredential("Discord", LLSD::emptyMap(), authenticator), true);
+ if (result.Successful())
+ {
+ gDiscordClient->UpdateToken(discordpp::AuthorizationTokenType::Bearer, accessToken, [accessToken](discordpp::ClientResult result) {
+ if (result.Successful())
+ {
+ LLSD authenticator = LLSD::emptyMap();
+ authenticator["token"] = accessToken;
+ gSecAPIHandler->saveCredential(gSecAPIHandler->createCredential("Discord", LLSD::emptyMap(), authenticator), true);
+ gDiscordClient->Connect();
+ }
+ else
+ {
+ LL_WARNS("Discord") << result.Error() << LL_ENDL;
+ }
+ });
+ }
+ else
+ {
+ LL_WARNS("Discord") << result.Error() << LL_ENDL;
+ }
});
}
else
{
+ LL_WARNS("Discord") << result.Error() << LL_ENDL;
gSavedSettings.setBOOL("EnableDiscord", false);
}
});
}
else
{
+ gDiscordClient->Disconnect();
auto credential = gSecAPIHandler->loadCredential("Discord");
if (credential.notNull())
{
gDiscordClient->RevokeToken(APPLICATION_ID, credential->getAuthenticator()["token"].asString(), [](discordpp::ClientResult result) {
if (result.Successful())
- {
- gDiscordClient->Disconnect();
- }
- auto cred = new LLCredential("Discord");
- gSecAPIHandler->deleteCredential(cred);
+ LL_INFOS("Discord") << "Access token successfully revoked." << LL_ENDL;
+ else
+ LL_WARNS("Discord") << "No access token to revoke." << LL_ENDL;
});
+ auto cred = new LLCredential("Discord");
+ gSecAPIHandler->deleteCredential(cred);
+ }
+ else
+ {
+ LL_WARNS("Discord") << "Credentials are already nonexistent." << LL_ENDL;
}
}
}