Purged kraken (#3578)

* Purged kraken code

* Remove kraken documentation

* Update Helix documentation

* Ran prettier

* Removed kraken files from qmake build file

* Remove now unnecessary .finally() callback
This commit is contained in:
Paweł
2022-02-28 14:59:10 +00:00
committed by GitHub
parent 6f7961444f
commit df70ca59e3
14 changed files with 57 additions and 329 deletions
+5 -102
View File
@@ -16,7 +16,6 @@
#include "providers/twitch/TwitchCommon.hpp"
#include "providers/twitch/TwitchUser.hpp"
#include "providers/twitch/api/Helix.hpp"
#include "providers/twitch/api/Kraken.hpp"
#include "singletons/Emotes.hpp"
#include "util/QStringHash.hpp"
#include "util/RapidjsonHelpers.hpp"
@@ -217,18 +216,7 @@ void TwitchAccount::loadEmotes(std::weak_ptr<Channel> weakChannel)
qCDebug(chatterinoTwitch) << "Cleared emotes!";
}
// TODO(zneix): Once Helix adds Get User Emotes we could remove this hacky solution
// For now, this is necessary as Kraken's equivalent doesn't return all emotes
// See: https://twitch.uservoice.com/forums/310213-developers/suggestions/43599900
this->loadUserstateEmotes([this, weakChannel] {
// Fill up emoteData with emote sets that were returned in a Kraken call, but aren't present in emoteData.
this->loadKrakenEmotes();
if (auto channel = weakChannel.lock(); channel != nullptr)
{
channel->addMessage(
makeSystemMessage("Twitch subscriber emotes reloaded."));
}
});
this->loadUserstateEmotes();
}
bool TwitchAccount::setUserstateEmoteSets(QStringList newEmoteSets)
@@ -246,15 +234,14 @@ bool TwitchAccount::setUserstateEmoteSets(QStringList newEmoteSets)
return true;
}
void TwitchAccount::loadUserstateEmotes(std::function<void()> callback)
void TwitchAccount::loadUserstateEmotes()
{
if (this->userstateEmoteSets_.isEmpty())
{
callback();
return;
}
QStringList newEmoteSetKeys, krakenEmoteSetKeys;
QStringList newEmoteSetKeys, existingEmoteSetKeys;
auto emoteData = this->emotes_.access();
auto userEmoteSets = emoteData->emoteSets;
@@ -262,13 +249,13 @@ void TwitchAccount::loadUserstateEmotes(std::function<void()> callback)
// get list of already fetched emote sets
for (const auto &userEmoteSet : userEmoteSets)
{
krakenEmoteSetKeys.push_back(userEmoteSet->key);
existingEmoteSetKeys.push_back(userEmoteSet->key);
}
// filter out emote sets from userstate message, which are not in fetched emote set list
for (const auto &emoteSetKey : qAsConst(this->userstateEmoteSets_))
{
if (!krakenEmoteSetKeys.contains(emoteSetKey))
if (!existingEmoteSetKeys.contains(emoteSetKey))
{
newEmoteSetKeys.push_back(emoteSetKey);
}
@@ -277,7 +264,6 @@ void TwitchAccount::loadUserstateEmotes(std::function<void()> callback)
// return if there are no new emote sets
if (newEmoteSetKeys.isEmpty())
{
callback();
return;
}
@@ -365,16 +351,6 @@ void TwitchAccount::loadUserstateEmotes(std::function<void()> callback)
},
[] {
// fetching emotes failed, ivr API might be down
},
[=] {
// XXX(zneix): We check if this is the last iteration and if so, call the callback
if (i + 1 == batches.size())
{
qCDebug(chatterinoTwitch)
<< "Finished loading emotes from IVR, attempting to "
"load Kraken emotes now";
callback();
}
});
};
}
@@ -484,79 +460,6 @@ void TwitchAccount::autoModDeny(const QString msgID, ChannelPtr channel)
});
}
void TwitchAccount::loadKrakenEmotes()
{
getKraken()->getUserEmotes(
this,
[this](KrakenEmoteSets data) {
// no emotes available
if (data.emoteSets.isEmpty())
{
qCWarning(chatterinoTwitch)
<< "\"emoticon_sets\" either empty or not present in "
"Kraken::getUserEmotes response";
return;
}
auto emoteData = this->emotes_.access();
for (auto emoteSetIt = data.emoteSets.begin();
emoteSetIt != data.emoteSets.end(); ++emoteSetIt)
{
auto emoteSet = std::make_shared<EmoteSet>();
QString setKey = emoteSetIt.key();
emoteSet->key = setKey;
this->loadEmoteSetData(emoteSet);
// check if the emoteset is already in emoteData
auto isAlreadyFetched = std::find_if(
emoteData->emoteSets.begin(), emoteData->emoteSets.end(),
[setKey](std::shared_ptr<EmoteSet> set) {
return (set->key == setKey);
});
if (isAlreadyFetched != emoteData->emoteSets.end())
{
continue;
}
for (const auto emoteArrObj : emoteSetIt->toArray())
{
if (!emoteArrObj.isObject())
{
qCWarning(chatterinoTwitch)
<< QString("Emote value from set %1 was invalid")
.arg(emoteSet->key);
continue;
}
KrakenEmote krakenEmote(emoteArrObj.toObject());
auto id = EmoteId{krakenEmote.id};
auto code = EmoteName{
TwitchEmotes::cleanUpEmoteCode(krakenEmote.code)};
emoteSet->emotes.emplace_back(TwitchEmote{id, code});
if (!emoteSet->local)
{
auto emote =
getApp()->emotes->twitch.getOrCreateEmote(id, code);
emoteData->emotes.emplace(code, emote);
}
}
std::sort(emoteSet->emotes.begin(), emoteSet->emotes.end(),
[](const TwitchEmote &l, const TwitchEmote &r) {
return l.name.string < r.name.string;
});
emoteData->emoteSets.emplace_back(emoteSet);
}
},
[] {
// kraken request failed
});
}
void TwitchAccount::loadEmoteSetData(std::shared_ptr<EmoteSet> emoteSet)
{
if (!emoteSet)