Skip to content

Commit

Permalink
BaseJob: Treat M_CONSENT_NOT_GIVEN separately from other content acce…
Browse files Browse the repository at this point in the history
…ss errors

Closes #207.
  • Loading branch information
KitsuneRal committed May 29, 2018
1 parent e58a03c commit c55c1cc
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
12 changes: 10 additions & 2 deletions lib/jobs/basejob.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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());
}
}
Expand Down Expand Up @@ -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&)
Expand Down
1 change: 1 addition & 0 deletions lib/jobs/basejob.h
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ namespace QMatrixClient
, TooManyRequestsError
, RequestNotImplementedError
, NetworkAuthRequiredError
, UserConsentRequiredError
, UserDefinedError = 200
};

Expand Down

0 comments on commit c55c1cc

Please sign in to comment.