Save the user defined domain instead of the one provided by login response
This commit is contained in:
parent
1f10403ace
commit
e78e43c86a
@ -44,7 +44,7 @@ public:
|
|||||||
void fetchOwnAvatar(const QUrl &avatar_url);
|
void fetchOwnAvatar(const QUrl &avatar_url);
|
||||||
void downloadImage(const QString &event_id, const QUrl &url);
|
void downloadImage(const QString &event_id, const QUrl &url);
|
||||||
|
|
||||||
inline QString getHomeServer();
|
inline QUrl getHomeServer();
|
||||||
inline int transactionId();
|
inline int transactionId();
|
||||||
inline void incrementTransactionId();
|
inline void incrementTransactionId();
|
||||||
|
|
||||||
@ -114,7 +114,7 @@ private:
|
|||||||
QString api_url_;
|
QString api_url_;
|
||||||
|
|
||||||
// The Matrix server used for communication.
|
// The Matrix server used for communication.
|
||||||
QString server_;
|
QUrl server_;
|
||||||
|
|
||||||
// The access token used for authentication.
|
// The access token used for authentication.
|
||||||
QString token_;
|
QString token_;
|
||||||
@ -126,7 +126,7 @@ private:
|
|||||||
QString next_batch_;
|
QString next_batch_;
|
||||||
};
|
};
|
||||||
|
|
||||||
inline QString MatrixClient::getHomeServer()
|
inline QUrl MatrixClient::getHomeServer()
|
||||||
{
|
{
|
||||||
return server_;
|
return server_;
|
||||||
}
|
}
|
||||||
@ -138,7 +138,7 @@ inline int MatrixClient::transactionId()
|
|||||||
|
|
||||||
inline void MatrixClient::setServer(const QString &server)
|
inline void MatrixClient::setServer(const QString &server)
|
||||||
{
|
{
|
||||||
server_ = "https://" + server;
|
server_ = QUrl(QString("https://%1").arg(server));
|
||||||
}
|
}
|
||||||
|
|
||||||
inline void MatrixClient::setAccessToken(const QString &token)
|
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];
|
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_);
|
client_.data()->downloadImage(event.eventId(), url_);
|
||||||
|
|
||||||
|
@ -94,9 +94,7 @@ void MatrixClient::onLoginResponse(QNetworkReply *reply)
|
|||||||
|
|
||||||
try {
|
try {
|
||||||
response.deserialize(json);
|
response.deserialize(json);
|
||||||
emit loginSuccess(response.getUserId(),
|
emit loginSuccess(response.getUserId(), server_.host(), response.getAccessToken());
|
||||||
response.getHomeServer(),
|
|
||||||
response.getAccessToken());
|
|
||||||
} catch (DeserializationException &e) {
|
} catch (DeserializationException &e) {
|
||||||
qWarning() << "Malformed JSON response" << e.what();
|
qWarning() << "Malformed JSON response" << e.what();
|
||||||
emit loginError("Malformed response. Possibly not a Matrix server");
|
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_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);
|
QNetworkRequest avatar_request(media_url);
|
||||||
|
|
||||||
@ -576,7 +574,7 @@ void MatrixClient::fetchOwnAvatar(const QUrl &avatar_url)
|
|||||||
}
|
}
|
||||||
|
|
||||||
QString media_params = url_parts[1];
|
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);
|
QNetworkRequest avatar_request(media_url);
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user