Fetch avatar thumbnail instead of the original image

closes #31
remotes/origin/HEAD
Konstantinos Sideris 8 years ago
parent 0cd9e3b1e5
commit f490040811
  1. 26
      src/MatrixClient.cc

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

Loading…
Cancel
Save