refactor(TwitchAccount): mostly include cleanup (#6182)

This commit is contained in:
pajlada
2025-05-03 12:19:15 +02:00
committed by GitHub
parent e38c64bac3
commit 54efa648b1
4 changed files with 17 additions and 21 deletions
+1
View File
@@ -33,6 +33,7 @@
- Dev: Save settings in `aboutToQuit`. (#6159) - Dev: Save settings in `aboutToQuit`. (#6159)
- Dev: Bumped deprecation cutoff to Qt 6.4.3. (#6169) - Dev: Bumped deprecation cutoff to Qt 6.4.3. (#6169)
- Dev: Updated GoogleTest to v1.17.0. (#6180) - Dev: Updated GoogleTest to v1.17.0. (#6180)
- Dev: Mini refactor of `TwitchAccount`. (#6182)
- Dev: Simplified string literals to be a re-export of Qt functions. (#6175) - Dev: Simplified string literals to be a re-export of Qt functions. (#6175)
## 2.5.3 ## 2.5.3
+2 -1
View File
@@ -1,9 +1,10 @@
#pragma once #pragma once
#include <boost/container_hash/hash_fwd.hpp> #include <boost/container_hash/hash_fwd.hpp>
#include <QHash> #include <QHashFunctions>
#include <QString> #include <QString>
#include <cstddef>
#include <functional> #include <functional>
// NOLINTNEXTLINE(cppcoreguidelines-macro-usage) // NOLINTNEXTLINE(cppcoreguidelines-macro-usage)
+8 -14
View File
@@ -2,33 +2,27 @@
#include "Application.hpp" #include "Application.hpp"
#include "common/Channel.hpp" #include "common/Channel.hpp"
#include "common/Env.hpp" #include "common/network/NetworkResult.hpp" // IWYU pragma: keep
#include "common/Literals.hpp"
#include "common/network/NetworkResult.hpp"
#include "common/QLogging.hpp" #include "common/QLogging.hpp"
#include "controllers/accounts/AccountController.hpp" #include "controllers/accounts/AccountController.hpp"
#include "debug/AssertInGuiThread.hpp" #include "debug/AssertInGuiThread.hpp"
#include "messages/Emote.hpp" #include "messages/Emote.hpp"
#include "messages/Message.hpp"
#include "messages/MessageBuilder.hpp" #include "messages/MessageBuilder.hpp"
#include "providers/IvrApi.hpp"
#include "providers/seventv/SeventvAPI.hpp" #include "providers/seventv/SeventvAPI.hpp"
#include "providers/twitch/api/Helix.hpp" #include "providers/twitch/api/Helix.hpp"
#include "providers/twitch/TwitchCommon.hpp" #include "providers/twitch/TwitchCommon.hpp"
#include "providers/twitch/TwitchUsers.hpp" #include "providers/twitch/TwitchUsers.hpp"
#include "singletons/Emotes.hpp" #include "singletons/Emotes.hpp"
#include "util/CancellationToken.hpp" #include "util/CancellationToken.hpp"
#include "util/Helpers.hpp" #include "util/QStringHash.hpp" // IWYU pragma: keep
#include "util/QStringHash.hpp"
#include "util/RapidjsonHelpers.hpp"
#include <boost/unordered/unordered_flat_map.hpp> #include <boost/unordered/unordered_flat_map.hpp>
#include <QStringBuilder> #include <QStringBuilder>
#include <QThread> #include <QThread>
namespace chatterino { using namespace Qt::Literals::StringLiterals;
using namespace literals; namespace chatterino {
TwitchAccount::TwitchAccount(const QString &username, const QString &oauthToken, TwitchAccount::TwitchAccount(const QString &username, const QString &oauthToken,
const QString &oauthClient, const QString &userID) const QString &oauthClient, const QString &userID)
@@ -215,7 +209,7 @@ const std::unordered_set<QString> &TwitchAccount::blockedUserLogins() const
} }
// AutoModActions // AutoModActions
void TwitchAccount::autoModAllow(const QString msgID, ChannelPtr channel) void TwitchAccount::autoModAllow(const QString &msgID, ChannelPtr channel) const
{ {
getHelix()->manageAutoModMessages( getHelix()->manageAutoModMessages(
this->getUserId(), msgID, "ALLOW", this->getUserId(), msgID, "ALLOW",
@@ -252,7 +246,7 @@ void TwitchAccount::autoModAllow(const QString msgID, ChannelPtr channel)
// This would most likely happen if the service is down, or if the JSON payload returned has changed format // This would most likely happen if the service is down, or if the JSON payload returned has changed format
case HelixAutoModMessageError::Unknown: case HelixAutoModMessageError::Unknown:
default: { default: {
errorMessage += "an unknown error occured."; errorMessage += "an unknown error occurred.";
} }
break; break;
} }
@@ -261,7 +255,7 @@ void TwitchAccount::autoModAllow(const QString msgID, ChannelPtr channel)
}); });
} }
void TwitchAccount::autoModDeny(const QString msgID, ChannelPtr channel) void TwitchAccount::autoModDeny(const QString &msgID, ChannelPtr channel) const
{ {
getHelix()->manageAutoModMessages( getHelix()->manageAutoModMessages(
this->getUserId(), msgID, "DENY", this->getUserId(), msgID, "DENY",
@@ -298,7 +292,7 @@ void TwitchAccount::autoModDeny(const QString msgID, ChannelPtr channel)
// This would most likely happen if the service is down, or if the JSON payload returned has changed format // This would most likely happen if the service is down, or if the JSON payload returned has changed format
case HelixAutoModMessageError::Unknown: case HelixAutoModMessageError::Unknown:
default: { default: {
errorMessage += "an unknown error occured."; errorMessage += "an unknown error occurred.";
} }
break; break;
} }
+6 -6
View File
@@ -1,5 +1,6 @@
#pragma once #pragma once
#include "common/Aliases.hpp"
#include "common/Atomic.hpp" #include "common/Atomic.hpp"
#include "common/UniqueAccess.hpp" #include "common/UniqueAccess.hpp"
#include "controllers/accounts/Account.hpp" #include "controllers/accounts/Account.hpp"
@@ -7,18 +8,17 @@
#include "providers/twitch/TwitchEmotes.hpp" #include "providers/twitch/TwitchEmotes.hpp"
#include "providers/twitch/TwitchUser.hpp" #include "providers/twitch/TwitchUser.hpp"
#include "util/CancellationToken.hpp" #include "util/CancellationToken.hpp"
#include "util/QStringHash.hpp"
#include <boost/unordered/unordered_flat_map_fwd.hpp>
#include <pajlada/signals.hpp> #include <pajlada/signals.hpp>
#include <QColor> #include <QColor>
#include <QElapsedTimer> #include <QElapsedTimer>
#include <QObject> #include <QObject>
#include <QString> #include <QString>
#include <rapidjson/document.h> #include <QtContainerFwd>
#include <functional> #include <functional>
#include <mutex> #include <memory>
#include <optional>
#include <unordered_set> #include <unordered_set>
namespace chatterino { namespace chatterino {
@@ -78,8 +78,8 @@ public:
[[nodiscard]] const std::unordered_set<QString> &blockedUserLogins() const; [[nodiscard]] const std::unordered_set<QString> &blockedUserLogins() const;
// Automod actions // Automod actions
void autoModAllow(const QString msgID, ChannelPtr channel); void autoModAllow(const QString &msgID, ChannelPtr channel) const;
void autoModDeny(const QString msgID, ChannelPtr channel); void autoModDeny(const QString &msgID, ChannelPtr channel) const;
void loadSeventvUserID(); void loadSeventvUserID();