Fix usage of FrankerFaceZ global emote API (#3921)

We no longer blindly parse all sets as global emotes, but rather match them against the default_sets as intended.

This means that some emotes will no longer be visible through Chatterino (e.g. AndKnuckles). This is more in line with how the FrankerFaceZ browser extension works.
This commit is contained in:
pajlada
2022-10-01 13:42:05 +02:00
committed by GitHub
parent d024a1ef7e
commit 5e02fdab52
2 changed files with 20 additions and 1 deletions
+19 -1
View File
@@ -56,12 +56,30 @@ namespace {
std::pair<Outcome, EmoteMap> parseGlobalEmotes(
const QJsonObject &jsonRoot, const EmoteMap &currentEmotes)
{
// Load default sets from the `default_sets` object
std::unordered_set<int> defaultSets{};
auto jsonDefaultSets = jsonRoot.value("default_sets").toArray();
for (auto jsonDefaultSet : jsonDefaultSets)
{
defaultSets.insert(jsonDefaultSet.toInt());
}
auto jsonSets = jsonRoot.value("sets").toObject();
auto emotes = EmoteMap();
for (auto jsonSet : jsonSets)
{
auto jsonEmotes = jsonSet.toObject().value("emoticons").toArray();
auto jsonSetObject = jsonSet.toObject();
const auto emoteSetID = jsonSetObject.value("id").toInt();
if (defaultSets.find(emoteSetID) == defaultSets.end())
{
qCDebug(chatterinoFfzemotes)
<< "Skipping global emote set" << emoteSetID
<< "as it's not part of the default sets";
continue;
}
auto jsonEmotes = jsonSetObject.value("emoticons").toArray();
for (auto jsonEmoteValue : jsonEmotes)
{