Skip to content
Snippets Groups Projects
Commit e78e43c8 authored by Konstantinos Sideris's avatar Konstantinos Sideris
Browse files

Save the user defined domain instead of the one provided by login response

parent 1f10403a
No related branches found
No related tags found
No related merge requests found
......@@ -44,7 +44,7 @@ public:
void fetchOwnAvatar(const QUrl &avatar_url);
void downloadImage(const QString &event_id, const QUrl &url);
inline QString getHomeServer();
inline QUrl getHomeServer();
inline int transactionId();
inline void incrementTransactionId();
......@@ -114,7 +114,7 @@ private:
QString api_url_;
// The Matrix server used for communication.
QString server_;
QUrl server_;
// The access token used for authentication.
QString token_;
......@@ -126,7 +126,7 @@ private:
QString next_batch_;
};
inline QString MatrixClient::getHomeServer()
inline QUrl MatrixClient::getHomeServer()
{
return server_;
}
......@@ -138,7 +138,7 @@ inline int MatrixClient::transactionId()
inline void MatrixClient::setServer(const QString &server)
{
server_ = "https://" + server;
server_ = QUrl(QString("https://%1").arg(server));
}
inline void MatrixClient::setAccessToken(const QString &token)
......
......@@ -49,7 +49,7 @@ ImageItem::ImageItem(QSharedPointer<MatrixClient> client, const events::MessageE
}
QString media_params = url_parts[1];
url_ = QString("%1/_matrix/media/r0/download/%2").arg(client_.data()->getHomeServer(), media_params);
url_ = QString("%1/_matrix/media/r0/download/%2").arg(client_.data()->getHomeServer().toString(), media_params);
client_.data()->downloadImage(event.eventId(), url_);
......
......@@ -94,9 +94,7 @@ void MatrixClient::onLoginResponse(QNetworkReply *reply)
try {
response.deserialize(json);
emit loginSuccess(response.getUserId(),
response.getHomeServer(),
response.getAccessToken());
emit loginSuccess(response.getUserId(), server_.host(), response.getAccessToken());
} catch (DeserializationException &e) {
qWarning() << "Malformed JSON response" << e.what();
emit loginError("Malformed response. Possibly not a Matrix server");
......@@ -548,7 +546,7 @@ void MatrixClient::fetchRoomAvatar(const QString &roomid, const QUrl &avatar_url
}
QString media_params = url_parts[1];
QString media_url = QString("%1/_matrix/media/r0/download/%2").arg(getHomeServer(), media_params);
QString media_url = QString("%1/_matrix/media/r0/download/%2").arg(getHomeServer().toString(), media_params);
QNetworkRequest avatar_request(media_url);
......@@ -576,7 +574,7 @@ void MatrixClient::fetchOwnAvatar(const QUrl &avatar_url)
}
QString media_params = url_parts[1];
QString media_url = QString("%1/_matrix/media/r0/download/%2").arg(getHomeServer(), media_params);
QString media_url = QString("%1/_matrix/media/r0/download/%2").arg(getHomeServer().toString(), media_params);
QNetworkRequest avatar_request(media_url);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment