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: Bumped deprecation cutoff to Qt 6.4.3. (#6169)
- 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)
## 2.5.3
+2 -1
View File
@@ -1,9 +1,10 @@
#pragma once
#include <boost/container_hash/hash_fwd.hpp>
#include <QHash>
#include <QHashFunctions>
#include <QString>
#include <cstddef>
#include <functional>
// NOLINTNEXTLINE(cppcoreguidelines-macro-usage)
+8 -14
View File
@@ -2,33 +2,27 @@
#include "Application.hpp"
#include "common/Channel.hpp"
#include "common/Env.hpp"
#include "common/Literals.hpp"
#include "common/network/NetworkResult.hpp"
#include "common/network/NetworkResult.hpp" // IWYU pragma: keep
#include "common/QLogging.hpp"
#include "controllers/accounts/AccountController.hpp"
#include "debug/AssertInGuiThread.hpp"
#include "messages/Emote.hpp"
#include "messages/Message.hpp"
#include "messages/MessageBuilder.hpp"
#include "providers/IvrApi.hpp"
#include "providers/seventv/SeventvAPI.hpp"
#include "providers/twitch/api/Helix.hpp"
#include "providers/twitch/TwitchCommon.hpp"
#include "providers/twitch/TwitchUsers.hpp"
#include "singletons/Emotes.hpp"
#include "util/CancellationToken.hpp"
#include "util/Helpers.hpp"
#include "util/QStringHash.hpp"
#include "util/RapidjsonHelpers.hpp"
#include "util/QStringHash.hpp" // IWYU pragma: keep
#include <boost/unordered/unordered_flat_map.hpp>
#include <QStringBuilder>
#include <QThread>
namespace chatterino {
using namespace Qt::Literals::StringLiterals;
using namespace literals;
namespace chatterino {
TwitchAccount::TwitchAccount(const QString &username, const QString &oauthToken,
const QString &oauthClient, const QString &userID)
@@ -215,7 +209,7 @@ const std::unordered_set<QString> &TwitchAccount::blockedUserLogins() const
}
// AutoModActions
void TwitchAccount::autoModAllow(const QString msgID, ChannelPtr channel)
void TwitchAccount::autoModAllow(const QString &msgID, ChannelPtr channel) const
{
getHelix()->manageAutoModMessages(
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
case HelixAutoModMessageError::Unknown:
default: {
errorMessage += "an unknown error occured.";
errorMessage += "an unknown error occurred.";
}
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(
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
case HelixAutoModMessageError::Unknown:
default: {
errorMessage += "an unknown error occured.";
errorMessage += "an unknown error occurred.";
}
break;
}
+6 -6
View File
@@ -1,5 +1,6 @@
#pragma once
#include "common/Aliases.hpp"
#include "common/Atomic.hpp"
#include "common/UniqueAccess.hpp"
#include "controllers/accounts/Account.hpp"
@@ -7,18 +8,17 @@
#include "providers/twitch/TwitchEmotes.hpp"
#include "providers/twitch/TwitchUser.hpp"
#include "util/CancellationToken.hpp"
#include "util/QStringHash.hpp"
#include <boost/unordered/unordered_flat_map_fwd.hpp>
#include <pajlada/signals.hpp>
#include <QColor>
#include <QElapsedTimer>
#include <QObject>
#include <QString>
#include <rapidjson/document.h>
#include <QtContainerFwd>
#include <functional>
#include <mutex>
#include <memory>
#include <optional>
#include <unordered_set>
namespace chatterino {
@@ -78,8 +78,8 @@ public:
[[nodiscard]] const std::unordered_set<QString> &blockedUserLogins() const;
// Automod actions
void autoModAllow(const QString msgID, ChannelPtr channel);
void autoModDeny(const QString msgID, ChannelPtr channel);
void autoModAllow(const QString &msgID, ChannelPtr channel) const;
void autoModDeny(const QString &msgID, ChannelPtr channel) const;
void loadSeventvUserID();