Commit 025e65ce authored by kaniini's avatar kaniini

account: handle redirection when fetching avatars

parent 782cf396
......@@ -754,10 +754,20 @@ void Identity::fetchAvatar(QUrl &avatar_url)
QNetworkRequest request = QNetworkRequest(avatar_url);
QNetworkReply *reply = m_parent->qnam()->get(request);
qDebug() << "GET" << avatar_url;
QObject::connect(reply, &QNetworkReply::finished, [=] () {
if (! reply->isFinished())
return;
// thanks Qt, I hate it.
QUrl redirect_url = reply->attribute(QNetworkRequest::RedirectionTargetAttribute).toUrl();
if (!redirect_url.isEmpty() && redirect_url != avatar_url)
{
fetchAvatar(redirect_url);
return;
}
auto data = reply->readAll();
m_avatar = QImage::fromData(data);
......
......@@ -39,6 +39,8 @@ void IdentityWidget::updateIdentity(const Michabo::Identity &identity)
m_display_name->setText(disp);
m_acct->setText(identity.m_acct);
qDebug() << "Avatar" << identity.m_avatar;
if (! identity.m_avatar.isNull())
{
m_avatar->setAvatar(identity.m_avatar);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment