Clean up TwitchAccount emote stuff (#4243)
* Remove unused TwitchAccount FollowResult enum * Remove unused TwitchEmoteSetResolverResponse struct * Remove unused and unimplemented `getEmoteSetBatches` function definition * Remove unused `loadEmoteSetData` and `staticEmoteSets` from TwitchAccount * Remove forward declaration of TwitchAccount in TwitchAccountManager * Clean up IgnorePhrase includes * add missing newline in pubsubmanager.cpp
This commit is contained in:
@@ -5,6 +5,7 @@
|
||||
#include "controllers/accounts/AccountController.hpp"
|
||||
#include "messages/LimitedQueue.hpp"
|
||||
#include "messages/Message.hpp"
|
||||
#include "providers/twitch/TwitchAccount.hpp"
|
||||
#include "providers/twitch/TwitchAccountManager.hpp"
|
||||
#include "providers/twitch/TwitchChannel.hpp"
|
||||
#include "providers/twitch/TwitchHelpers.hpp"
|
||||
|
||||
@@ -4,6 +4,7 @@
|
||||
#include "providers/twitch/PubSubActions.hpp"
|
||||
#include "providers/twitch/PubSubHelpers.hpp"
|
||||
#include "providers/twitch/PubSubMessages.hpp"
|
||||
#include "providers/twitch/TwitchAccount.hpp"
|
||||
#include "util/DebugCount.hpp"
|
||||
#include "util/Helpers.hpp"
|
||||
#include "util/RapidjsonHelpers.hpp"
|
||||
@@ -476,6 +477,18 @@ PubSub::PubSub(const QString &host, std::chrono::seconds pingInterval)
|
||||
bind(&PubSub::onConnectionFail, this, ::_1));
|
||||
}
|
||||
|
||||
void PubSub::setAccount(std::shared_ptr<TwitchAccount> account)
|
||||
{
|
||||
this->token_ = account->getOAuthToken();
|
||||
this->userID_ = account->getUserId();
|
||||
}
|
||||
|
||||
void PubSub::setAccountData(QString token, QString userID)
|
||||
{
|
||||
this->token_ = token;
|
||||
this->userID_ = userID;
|
||||
}
|
||||
|
||||
void PubSub::addClient()
|
||||
{
|
||||
if (this->addingClient)
|
||||
|
||||
@@ -6,8 +6,8 @@
|
||||
#include "providers/twitch/PubSubClientOptions.hpp"
|
||||
#include "providers/twitch/PubSubMessages.hpp"
|
||||
#include "providers/twitch/PubSubWebsocket.hpp"
|
||||
#include "providers/twitch/TwitchAccount.hpp"
|
||||
#include "util/ExponentialBackoff.hpp"
|
||||
#include "util/QStringHash.hpp"
|
||||
|
||||
#include <pajlada/signals/signal.hpp>
|
||||
#include <QJsonObject>
|
||||
@@ -24,6 +24,8 @@
|
||||
|
||||
namespace chatterino {
|
||||
|
||||
class TwitchAccount;
|
||||
|
||||
class PubSub
|
||||
{
|
||||
using WebsocketMessagePtr =
|
||||
@@ -57,17 +59,9 @@ public:
|
||||
PubSub(const QString &host,
|
||||
std::chrono::seconds pingInterval = std::chrono::seconds(15));
|
||||
|
||||
void setAccount(std::shared_ptr<TwitchAccount> account)
|
||||
{
|
||||
this->token_ = account->getOAuthToken();
|
||||
this->userID_ = account->getUserId();
|
||||
}
|
||||
void setAccount(std::shared_ptr<TwitchAccount> account);
|
||||
|
||||
void setAccountData(QString token, QString userID)
|
||||
{
|
||||
this->token_ = token;
|
||||
this->userID_ = userID;
|
||||
}
|
||||
void setAccountData(QString token, QString userID);
|
||||
|
||||
~PubSub() = delete;
|
||||
|
||||
|
||||
@@ -442,71 +442,4 @@ void TwitchAccount::autoModDeny(const QString msgID, ChannelPtr channel)
|
||||
});
|
||||
}
|
||||
|
||||
void TwitchAccount::loadEmoteSetData(std::shared_ptr<EmoteSet> emoteSet)
|
||||
{
|
||||
if (!emoteSet)
|
||||
{
|
||||
qCWarning(chatterinoTwitch) << "null emote set sent";
|
||||
return;
|
||||
}
|
||||
|
||||
auto staticSetIt = this->staticEmoteSets.find(emoteSet->key);
|
||||
if (staticSetIt != this->staticEmoteSets.end())
|
||||
{
|
||||
const auto &staticSet = staticSetIt->second;
|
||||
emoteSet->channelName = staticSet.channelName;
|
||||
emoteSet->text = staticSet.text;
|
||||
return;
|
||||
}
|
||||
|
||||
getHelix()->getEmoteSetData(
|
||||
emoteSet->key,
|
||||
[emoteSet](HelixEmoteSetData emoteSetData) {
|
||||
// Follower emotes can be only used in their origin channel
|
||||
if (emoteSetData.emoteType == "follower")
|
||||
{
|
||||
emoteSet->local = true;
|
||||
}
|
||||
|
||||
if (emoteSetData.ownerId.isEmpty() ||
|
||||
emoteSetData.setId != emoteSet->key)
|
||||
{
|
||||
qCDebug(chatterinoTwitch)
|
||||
<< QString("Failed to fetch emoteSetData for %1, assuming "
|
||||
"Twitch is the owner")
|
||||
.arg(emoteSet->key);
|
||||
|
||||
// most (if not all) emotes that fail to load are time limited event emotes owned by Twitch
|
||||
emoteSet->channelName = "twitch";
|
||||
emoteSet->text = "Twitch";
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
// emote set 0 = global emotes
|
||||
if (emoteSetData.ownerId == "0")
|
||||
{
|
||||
// emoteSet->channelName = QString();
|
||||
emoteSet->text = "Twitch Global";
|
||||
return;
|
||||
}
|
||||
|
||||
getHelix()->getUserById(
|
||||
emoteSetData.ownerId,
|
||||
[emoteSet](HelixUser user) {
|
||||
emoteSet->channelName = user.login;
|
||||
emoteSet->text = user.displayName;
|
||||
},
|
||||
[emoteSetData] {
|
||||
qCWarning(chatterinoTwitch)
|
||||
<< "Failed to query user by id:" << emoteSetData.ownerId
|
||||
<< emoteSetData.setId;
|
||||
});
|
||||
},
|
||||
[emoteSet] {
|
||||
// fetching emoteset data failed
|
||||
return;
|
||||
});
|
||||
}
|
||||
|
||||
} // namespace chatterino
|
||||
|
||||
@@ -20,39 +20,6 @@
|
||||
|
||||
namespace chatterino {
|
||||
|
||||
enum FollowResult {
|
||||
FollowResult_Following,
|
||||
FollowResult_NotFollowing,
|
||||
FollowResult_Failed,
|
||||
};
|
||||
|
||||
struct TwitchEmoteSetResolverResponse {
|
||||
const QString channelName;
|
||||
const QString channelId;
|
||||
const QString type;
|
||||
const int tier;
|
||||
const bool isCustom;
|
||||
// Example response:
|
||||
// {
|
||||
// "channel_name": "zneix",
|
||||
// "channel_id": "99631238",
|
||||
// "type": "",
|
||||
// "tier": 1,
|
||||
// "custom": false
|
||||
// }
|
||||
|
||||
TwitchEmoteSetResolverResponse(QJsonObject jsonObject)
|
||||
: channelName(jsonObject.value("channel_name").toString())
|
||||
, channelId(jsonObject.value("channel_id").toString())
|
||||
, type(jsonObject.value("type").toString())
|
||||
, tier(jsonObject.value("tier").toInt())
|
||||
, isCustom(jsonObject.value("custom").toBool())
|
||||
{
|
||||
}
|
||||
};
|
||||
|
||||
std::vector<QStringList> getEmoteSetBatches(QStringList emoteSetKeys);
|
||||
|
||||
class TwitchAccount : public Account
|
||||
{
|
||||
public:
|
||||
@@ -69,8 +36,6 @@ public:
|
||||
std::vector<TwitchEmote> emotes;
|
||||
};
|
||||
|
||||
std::map<QString, EmoteSet> staticEmoteSets;
|
||||
|
||||
struct TwitchAccountEmoteData {
|
||||
std::vector<std::shared_ptr<EmoteSet>> emoteSets;
|
||||
|
||||
@@ -127,8 +92,6 @@ public:
|
||||
void autoModDeny(const QString msgID, ChannelPtr channel);
|
||||
|
||||
private:
|
||||
void loadEmoteSetData(std::shared_ptr<EmoteSet> emoteSet);
|
||||
|
||||
QString oauthClient_;
|
||||
QString oauthToken_;
|
||||
QString userName_;
|
||||
|
||||
@@ -2,7 +2,6 @@
|
||||
|
||||
#include "common/ChatterinoSetting.hpp"
|
||||
#include "common/SignalVector.hpp"
|
||||
#include "providers/twitch/TwitchAccount.hpp"
|
||||
#include "util/SharedPtrElementLess.hpp"
|
||||
|
||||
#include <boost/signals2.hpp>
|
||||
|
||||
@@ -6,6 +6,7 @@
|
||||
#include "common/QLogging.hpp"
|
||||
#include "controllers/accounts/AccountController.hpp"
|
||||
#include "controllers/notifications/NotificationController.hpp"
|
||||
#include "messages/Emote.hpp"
|
||||
#include "messages/Message.hpp"
|
||||
#include "providers/bttv/BttvEmotes.hpp"
|
||||
#include "providers/bttv/LoadBttvChannelEmote.hpp"
|
||||
@@ -15,6 +16,7 @@
|
||||
#include "providers/twitch/api/Helix.hpp"
|
||||
#include "providers/twitch/IrcMessageHandler.hpp"
|
||||
#include "providers/twitch/PubSubManager.hpp"
|
||||
#include "providers/twitch/TwitchAccount.hpp"
|
||||
#include "providers/twitch/TwitchCommon.hpp"
|
||||
#include "providers/twitch/TwitchIrcServer.hpp"
|
||||
#include "providers/twitch/TwitchMessageBuilder.hpp"
|
||||
|
||||
@@ -6,10 +6,12 @@
|
||||
#include "controllers/ignores/IgnoreController.hpp"
|
||||
#include "controllers/ignores/IgnorePhrase.hpp"
|
||||
#include "controllers/userdata/UserDataController.hpp"
|
||||
#include "messages/Emote.hpp"
|
||||
#include "messages/Message.hpp"
|
||||
#include "providers/chatterino/ChatterinoBadges.hpp"
|
||||
#include "providers/ffz/FfzBadges.hpp"
|
||||
#include "providers/seventv/SeventvBadges.hpp"
|
||||
#include "providers/twitch/TwitchAccount.hpp"
|
||||
#include "providers/twitch/TwitchBadge.hpp"
|
||||
#include "providers/twitch/TwitchBadges.hpp"
|
||||
#include "providers/twitch/TwitchChannel.hpp"
|
||||
|
||||
Reference in New Issue
Block a user