Fetch avatar thumbnail instead of the original image

closes #31
This commit is contained in:
Konstantinos Sideris 2017-05-27 01:29:45 +03:00
parent 0cd9e3b1e5
commit f490040811

View file

@ -574,10 +574,17 @@ void MatrixClient::fetchRoomAvatar(const QString &roomid, const QUrl &avatar_url
return; return;
} }
QString media_params = url_parts[1]; QUrlQuery query;
QString media_url = QString("%1/_matrix/media/r0/download/%2").arg(getHomeServer().toString(), media_params); query.addQueryItem("width", "512");
query.addQueryItem("height", "512");
query.addQueryItem("method", "crop");
QNetworkRequest avatar_request(media_url); QString media_url = QString("%1/_matrix/media/r0/thumbnail/%2").arg(getHomeServer().toString(), url_parts[1]);
QUrl endpoint(media_url);
endpoint.setQuery(query);
QNetworkRequest avatar_request(endpoint);
QNetworkReply *reply = get(avatar_request); QNetworkReply *reply = get(avatar_request);
reply->setProperty("roomid", roomid); reply->setProperty("roomid", roomid);
@ -602,10 +609,17 @@ void MatrixClient::fetchOwnAvatar(const QUrl &avatar_url)
return; return;
} }
QString media_params = url_parts[1]; QUrlQuery query;
QString media_url = QString("%1/_matrix/media/r0/download/%2").arg(getHomeServer().toString(), media_params); query.addQueryItem("width", "512");
query.addQueryItem("height", "512");
query.addQueryItem("method", "crop");
QNetworkRequest avatar_request(media_url); QString media_url = QString("%1/_matrix/media/r0/thumbnail/%2").arg(getHomeServer().toString(), url_parts[1]);
QUrl endpoint(media_url);
endpoint.setQuery(query);
QNetworkRequest avatar_request(endpoint);
QNetworkReply *reply = get(avatar_request); QNetworkReply *reply = get(avatar_request);
reply->setProperty("endpoint", static_cast<int>(Endpoint::GetOwnAvatar)); reply->setProperty("endpoint", static_cast<int>(Endpoint::GetOwnAvatar));