mirror of
https://github.com/Nheko-Reborn/nheko.git
synced 2024-11-29 14:18:49 +03:00
Fallback to the login screen when the one-time keys cannot be uploaded
This commit is contained in:
parent
cbff9c6914
commit
797a69fd90
1 changed files with 13 additions and 6 deletions
|
@ -50,6 +50,7 @@ static const std::string STORAGE_SECRET_KEY("secret");
|
||||||
|
|
||||||
ChatPage *ChatPage::instance_ = nullptr;
|
ChatPage *ChatPage::instance_ = nullptr;
|
||||||
constexpr int CHECK_CONNECTIVITY_INTERVAL = 15'000;
|
constexpr int CHECK_CONNECTIVITY_INTERVAL = 15'000;
|
||||||
|
constexpr int RETRY_TIMEOUT = 5'000;
|
||||||
constexpr size_t MAX_ONETIME_KEYS = 50;
|
constexpr size_t MAX_ONETIME_KEYS = 50;
|
||||||
|
|
||||||
ChatPage::ChatPage(QSharedPointer<UserSettings> userSettings, QWidget *parent)
|
ChatPage::ChatPage(QSharedPointer<UserSettings> userSettings, QWidget *parent)
|
||||||
|
@ -585,7 +586,7 @@ ChatPage::ChatPage(QSharedPointer<UserSettings> userSettings, QWidget *parent)
|
||||||
connect(this, &ChatPage::tryInitialSyncCb, this, &ChatPage::tryInitialSync);
|
connect(this, &ChatPage::tryInitialSyncCb, this, &ChatPage::tryInitialSync);
|
||||||
connect(this, &ChatPage::trySyncCb, this, &ChatPage::trySync);
|
connect(this, &ChatPage::trySyncCb, this, &ChatPage::trySync);
|
||||||
connect(this, &ChatPage::tryDelayedSyncCb, this, [this]() {
|
connect(this, &ChatPage::tryDelayedSyncCb, this, [this]() {
|
||||||
QTimer::singleShot(5000, this, &ChatPage::trySync);
|
QTimer::singleShot(RETRY_TIMEOUT, this, &ChatPage::trySync);
|
||||||
});
|
});
|
||||||
|
|
||||||
connect(this, &ChatPage::dropToLoginPageCb, this, &ChatPage::dropToLoginPage);
|
connect(this, &ChatPage::dropToLoginPageCb, this, &ChatPage::dropToLoginPage);
|
||||||
|
@ -957,17 +958,23 @@ ChatPage::tryInitialSync()
|
||||||
[this](const mtx::responses::UploadKeys &res, mtx::http::RequestErr err) {
|
[this](const mtx::responses::UploadKeys &res, mtx::http::RequestErr err) {
|
||||||
if (err) {
|
if (err) {
|
||||||
const int status_code = static_cast<int>(err->status_code);
|
const int status_code = static_cast<int>(err->status_code);
|
||||||
nhlog::crypto()->critical("failed to upload one time keys: {} {}",
|
|
||||||
err->matrix_error.error,
|
|
||||||
status_code);
|
|
||||||
if (status_code == 404) {
|
if (status_code == 404) {
|
||||||
nhlog::net()->warn(
|
nhlog::net()->warn(
|
||||||
"skipping key uploading. server doesn't provide /keys/upload");
|
"skipping key uploading. server doesn't provide /keys/upload");
|
||||||
return startInitialSync();
|
return startInitialSync();
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO We should have a timeout instead of keeping hammering the server.
|
nhlog::crypto()->critical("failed to upload one time keys: {} {}",
|
||||||
emit tryInitialSyncCb();
|
err->matrix_error.error,
|
||||||
|
status_code);
|
||||||
|
|
||||||
|
QString errorMsg(tr("Failed to setup encryption keys. Server response: "
|
||||||
|
"%s %d. Please try again later.")
|
||||||
|
.arg(QString::fromStdString(err->matrix_error.error))
|
||||||
|
.arg(status_code));
|
||||||
|
|
||||||
|
emit dropToLoginPageCb(errorMsg);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue