mirror of
https://github.com/overte-org/overte.git
synced 2025-08-04 05:23:33 +02:00
Commerce: Fix Certificate Info error
This commit is contained in:
parent
a9b9a1cb10
commit
ffab27d442
2 changed files with 34 additions and 8 deletions
|
@ -51,7 +51,24 @@ Rectangle {
|
||||||
|
|
||||||
onCertificateInfoResult: {
|
onCertificateInfoResult: {
|
||||||
if (result.status !== 'success') {
|
if (result.status !== 'success') {
|
||||||
console.log("Failed to get certificate info", result.message);
|
console.log("Failed to get certificate info", result.data.message);
|
||||||
|
// We should still tell the user that static cert verification failed
|
||||||
|
if (root.certificateStatus !== 3) { // CERTIFICATE_STATUS_STATIC_VERIFICATION_FAILED
|
||||||
|
root.useGoldCert = false;
|
||||||
|
root.certTitleTextColor = hifi.colors.redHighlight;
|
||||||
|
root.certTextColor = hifi.colors.redHighlight;
|
||||||
|
root.infoTextColor = hifi.colors.redHighlight;
|
||||||
|
titleBarText.text = "Certificate Unavailable";
|
||||||
|
popText.text = "";
|
||||||
|
showInMarketplaceButton.visible = false;
|
||||||
|
root.certInfoReplaceMode = 0;
|
||||||
|
root.itemName = "";
|
||||||
|
root.itemEdition = "";
|
||||||
|
root.itemOwner = "";
|
||||||
|
root.dateOfPurchase = "";
|
||||||
|
root.itemCost = "";
|
||||||
|
errorText.text = "Information about this certificate is currently unavailable. Please try again later.";
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
root.marketplaceUrl = result.data.marketplace_item_url;
|
root.marketplaceUrl = result.data.marketplace_item_url;
|
||||||
root.isMyCert = result.isMyCert ? result.isMyCert : false;
|
root.isMyCert = result.isMyCert ? result.isMyCert : false;
|
||||||
|
|
|
@ -35,12 +35,19 @@ QJsonObject Ledger::apiResponse(const QString& label, QNetworkReply& reply) {
|
||||||
QJsonObject Ledger::failResponse(const QString& label, QNetworkReply& reply) {
|
QJsonObject Ledger::failResponse(const QString& label, QNetworkReply& reply) {
|
||||||
QString response = reply.readAll();
|
QString response = reply.readAll();
|
||||||
qWarning(commerce) << "FAILED" << label << response;
|
qWarning(commerce) << "FAILED" << label << response;
|
||||||
|
|
||||||
|
// tempResult will be NULL if the response isn't valid JSON.
|
||||||
|
QJsonDocument tempResult = QJsonDocument::fromJson(response.toLocal8Bit());
|
||||||
|
if (tempResult.isNull()) {
|
||||||
QJsonObject result
|
QJsonObject result
|
||||||
{
|
{
|
||||||
{ "status", "fail" },
|
{ "status", "fail" },
|
||||||
{ "message", response }
|
{ "message", response }
|
||||||
};
|
};
|
||||||
return result;
|
return result;
|
||||||
|
} else {
|
||||||
|
return tempResult.object();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
#define ApiHandler(NAME) void Ledger::NAME##Success(QNetworkReply& reply) { emit NAME##Result(apiResponse(#NAME, reply)); }
|
#define ApiHandler(NAME) void Ledger::NAME##Success(QNetworkReply& reply) { emit NAME##Result(apiResponse(#NAME, reply)); }
|
||||||
#define FailHandler(NAME) void Ledger::NAME##Failure(QNetworkReply& reply) { emit NAME##Result(failResponse(#NAME, reply)); }
|
#define FailHandler(NAME) void Ledger::NAME##Failure(QNetworkReply& reply) { emit NAME##Result(failResponse(#NAME, reply)); }
|
||||||
|
@ -337,7 +344,9 @@ void Ledger::certificateInfoSuccess(QNetworkReply& reply) {
|
||||||
qInfo(commerce) << "certificateInfo" << "response" << QJsonDocument(replyObject).toJson(QJsonDocument::Compact);
|
qInfo(commerce) << "certificateInfo" << "response" << QJsonDocument(replyObject).toJson(QJsonDocument::Compact);
|
||||||
emit certificateInfoResult(replyObject);
|
emit certificateInfoResult(replyObject);
|
||||||
}
|
}
|
||||||
void Ledger::certificateInfoFailure(QNetworkReply& reply) { failResponse("certificateInfo", reply); }
|
void Ledger::certificateInfoFailure(QNetworkReply& reply) {
|
||||||
|
emit certificateInfoResult(failResponse("certificateInfo", reply));
|
||||||
|
}
|
||||||
void Ledger::certificateInfo(const QString& certificateId) {
|
void Ledger::certificateInfo(const QString& certificateId) {
|
||||||
QString endpoint = "proof_of_purchase_status/transfer";
|
QString endpoint = "proof_of_purchase_status/transfer";
|
||||||
QJsonObject request;
|
QJsonObject request;
|
||||||
|
|
Loading…
Reference in a new issue