Fix Handling of FFZ CDN URLs with https already appended (#4432)

This commit is contained in:
Daniel Sage 2023-03-04 19:34:36 -05:00 committed by GitHub
parent 1dc2bcc445
commit b9e87dcd2b
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
6 changed files with 37 additions and 9 deletions

View file

@ -4,6 +4,7 @@
- Minor: Delete all but the last 5 crashdumps on application start. (#4392)
- Minor: Added `/banid` command that allows banning by user ID. (#4411)
- Bugfix: Fixed FrankerFaceZ emotes/badges not loading due to API change. (#4432)
- Bugfix: Fixed uploaded AppImage not being able most web requests. (#4400)
- Bugfix: Fixed a potential race condition due to using the wrong lock when loading 7TV badges. (#4402)
- Dev: Add capability to build Chatterino with Qt6. (#4393)

View file

@ -225,6 +225,8 @@ set(SOURCE_FILES
providers/ffz/FfzBadges.hpp
providers/ffz/FfzEmotes.cpp
providers/ffz/FfzEmotes.hpp
providers/ffz/FfzUtil.cpp
providers/ffz/FfzUtil.hpp
providers/irc/AbstractIrcServer.cpp
providers/irc/AbstractIrcServer.hpp

View file

@ -4,6 +4,7 @@
#include "common/NetworkResult.hpp"
#include "common/Outcome.hpp"
#include "messages/Emote.hpp"
#include "providers/ffz/FfzUtil.hpp"
#include <QJsonArray>
#include <QJsonObject>
@ -67,14 +68,12 @@ void FfzBadges::load()
auto jsonBadge = jsonBadge_.toObject();
auto jsonUrls = jsonBadge.value("urls").toObject();
auto emote = Emote{
EmoteName{},
ImageSet{
Url{QString("https:") + jsonUrls.value("1").toString()},
Url{QString("https:") + jsonUrls.value("2").toString()},
Url{QString("https:") +
jsonUrls.value("4").toString()}},
Tooltip{jsonBadge.value("title").toString()}, Url{}};
auto emote =
Emote{EmoteName{},
ImageSet{parseFfzUrl(jsonUrls.value("1").toString()),
parseFfzUrl(jsonUrls.value("2").toString()),
parseFfzUrl(jsonUrls.value("4").toString())},
Tooltip{jsonBadge.value("title").toString()}, Url{}};
Badge badge;

View file

@ -7,6 +7,7 @@
#include "messages/Emote.hpp"
#include "messages/Image.hpp"
#include "messages/MessageBuilder.hpp"
#include "providers/ffz/FfzUtil.hpp"
#include "providers/twitch/TwitchChannel.hpp"
#include "singletons/Settings.hpp"
@ -26,8 +27,9 @@ namespace {
assert(emote.isString());
return {"https:" + emote.toString()};
return parseFfzUrl(emote.toString());
}
void fillInEmoteData(const QJsonObject &urls, const EmoteName &name,
const QString &tooltip, Emote &emoteData)
{

View file

@ -0,0 +1,12 @@
#include "providers/ffz/FfzUtil.hpp"
namespace chatterino {
Url parseFfzUrl(const QString &ffzUrl)
{
QUrl asURL(ffzUrl);
asURL.setScheme("https");
return {asURL.toString()};
}
} // namespace chatterino

View file

@ -0,0 +1,12 @@
#pragma once
#include "common/Aliases.hpp"
#include <QString>
#include <QUrl>
namespace chatterino {
Url parseFfzUrl(const QString &ffzUrl);
} // namespace chatterino