From c55c1cc83985f808e9cfc7475e5113566a1ac5a8 Mon Sep 17 00:00:00 2001 From: Kitsune Ral Date: Tue, 29 May 2018 16:48:54 +0900 Subject: BaseJob: Treat M_CONSENT_NOT_GIVEN separately from other content access errors Closes #207. --- lib/jobs/basejob.cpp | 12 ++++++++++-- lib/jobs/basejob.h | 1 + 2 files changed, 11 insertions(+), 2 deletions(-) (limited to 'lib') diff --git a/lib/jobs/basejob.cpp b/lib/jobs/basejob.cpp index 37ecad18..a8fc0adc 100644 --- a/lib/jobs/basejob.cpp +++ b/lib/jobs/basejob.cpp @@ -313,7 +313,15 @@ void BaseJob::gotReply() emit retryScheduled(d->retriesTaken, retryInterval); return; } - if (!json.isEmpty()) + if (json.value("errcode").toString() == "M_CONSENT_NOT_GIVEN") + { + auto urlString = json.value("consent_uri").toString(); + setStatus(UserConsentRequiredError, + tr("You must agree with the server's privacy policy; " + "please visit %1").arg(urlString)); + d->errorUrl = urlString; + } + if (!json.isEmpty()) // FIXME: The below is not localisable setStatus(IncorrectRequestError, json.value("error").toString()); } } @@ -414,7 +422,7 @@ BaseJob::Status BaseJob::parseReply(QNetworkReply* reply) if( error.error == QJsonParseError::NoError ) return parseJson(json); else - return { JsonParseError, error.errorString() }; + return { IncorrectResponseError, error.errorString() }; } BaseJob::Status BaseJob::parseJson(const QJsonDocument&) diff --git a/lib/jobs/basejob.h b/lib/jobs/basejob.h index 25f13472..0d791d3a 100644 --- a/lib/jobs/basejob.h +++ b/lib/jobs/basejob.h @@ -65,6 +65,7 @@ namespace QMatrixClient , TooManyRequestsError , RequestNotImplementedError , NetworkAuthRequiredError + , UserConsentRequiredError , UserDefinedError = 200 }; -- cgit v1.2.3