mirror of
https://github.com/Chatterino/chatterino2.git
synced 2024-11-21 22:24:07 +01:00
Only attempt to read thumbnails when we get a 200 response code.
We would have been able to keep doing this if the Network Request code followed redirects - however, it doesn't, so this is the best we can do. We also don't have header support in Network Result, so we can't validate that the response we got is actually an image. Fixes #1972
This commit is contained in:
parent
8123a47898
commit
4f35842473
1 changed files with 12 additions and 3 deletions
|
@ -594,6 +594,7 @@ void SplitHeader::updateChannelText()
|
||||||
if (streamStatus->live)
|
if (streamStatus->live)
|
||||||
{
|
{
|
||||||
this->isLive_ = true;
|
this->isLive_ = true;
|
||||||
|
// XXX: This URL format can be figured out from the Helix Get Streams API which we parse in TwitchChannel::parseLiveStatus
|
||||||
QString url = "https://static-cdn.jtvnw.net/"
|
QString url = "https://static-cdn.jtvnw.net/"
|
||||||
"previews-ttv/live_user_" +
|
"previews-ttv/live_user_" +
|
||||||
channel->getName().toLower();
|
channel->getName().toLower();
|
||||||
|
@ -617,9 +618,17 @@ void SplitHeader::updateChannelText()
|
||||||
{
|
{
|
||||||
NetworkRequest(url, NetworkRequestType::Get)
|
NetworkRequest(url, NetworkRequestType::Get)
|
||||||
.onSuccess([this](auto result) -> Outcome {
|
.onSuccess([this](auto result) -> Outcome {
|
||||||
this->thumbnail_ =
|
// NOTE: We do not follow the redirects, so we need to make sure we only treat code 200 as a valid image
|
||||||
QString::fromLatin1(result.getData().toBase64());
|
if (result.status() == 200)
|
||||||
updateChannelText();
|
{
|
||||||
|
this->thumbnail_ = QString::fromLatin1(
|
||||||
|
result.getData().toBase64());
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
this->thumbnail_.clear();
|
||||||
|
}
|
||||||
|
this->updateChannelText();
|
||||||
return Success;
|
return Success;
|
||||||
})
|
})
|
||||||
.execute();
|
.execute();
|
||||||
|
|
Loading…
Reference in a new issue