Merge pull request #13035 from zfox23/RC67_updateCommerceFor67

RC67: Allow gifting of Pending items; remove PoP verification rescheduling on Pending items
This commit is contained in:
John Conklin II 2018-04-27 14:46:24 -07:00 committed by GitHub
commit 9bf5549000
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
6 changed files with 23 additions and 47 deletions

View file

@ -1308,7 +1308,7 @@ Item {
anchors.right: parent.right; anchors.right: parent.right;
anchors.rightMargin: root.assetName === "" ? 15 : 50; anchors.rightMargin: root.assetName === "" ? 15 : 50;
anchors.bottom: parent.bottom; anchors.bottom: parent.bottom;
anchors.bottomMargin: root.assetName === "" ? 15 : 300; anchors.bottomMargin: root.assetName === "" ? 15 : 240;
color: "#FFFFFF"; color: "#FFFFFF";
RalewaySemiBold { RalewaySemiBold {
@ -1403,12 +1403,12 @@ Item {
id: giftContainer_paymentSuccess; id: giftContainer_paymentSuccess;
visible: root.assetName !== ""; visible: root.assetName !== "";
anchors.top: sendToContainer_paymentSuccess.bottom; anchors.top: sendToContainer_paymentSuccess.bottom;
anchors.topMargin: 16; anchors.topMargin: 8;
anchors.left: parent.left; anchors.left: parent.left;
anchors.leftMargin: 20; anchors.leftMargin: 20;
anchors.right: parent.right; anchors.right: parent.right;
anchors.rightMargin: 20; anchors.rightMargin: 20;
height: 80; height: 30;
RalewaySemiBold { RalewaySemiBold {
id: gift_paymentSuccess; id: gift_paymentSuccess;
@ -1431,6 +1431,7 @@ Item {
anchors.top: parent.top; anchors.top: parent.top;
anchors.left: gift_paymentSuccess.right; anchors.left: gift_paymentSuccess.right;
anchors.right: parent.right; anchors.right: parent.right;
height: parent.height;
// Text size // Text size
size: 18; size: 18;
// Style // Style
@ -1522,7 +1523,7 @@ Item {
colorScheme: root.assetName === "" ? hifi.colorSchemes.dark : hifi.colorSchemes.light; colorScheme: root.assetName === "" ? hifi.colorSchemes.dark : hifi.colorSchemes.light;
anchors.horizontalCenter: parent.horizontalCenter; anchors.horizontalCenter: parent.horizontalCenter;
anchors.bottom: parent.bottom; anchors.bottom: parent.bottom;
anchors.bottomMargin: 80; anchors.bottomMargin: root.assetName === "" ? 80 : 30;
height: 50; height: 50;
width: 120; width: 120;
text: "Close"; text: "Close";

View file

@ -239,7 +239,6 @@ Item {
width: 62; width: 62;
onLoaded: { onLoaded: {
item.enabled = (root.purchaseStatus === "confirmed");
item.buttonGlyphText = hifi.glyphs.gift; item.buttonGlyphText = hifi.glyphs.gift;
item.buttonText = "Gift"; item.buttonText = "Gift";
item.buttonClicked = function() { item.buttonClicked = function() {

View file

@ -1172,16 +1172,6 @@ void EntityTree::startChallengeOwnershipTimer(const EntityItemID& entityItemID)
_challengeOwnershipTimeoutTimer->start(5000); _challengeOwnershipTimeoutTimer->start(5000);
} }
void EntityTree::startPendingTransferStatusTimer(const QString& certID, const EntityItemID& entityItemID, const SharedNodePointer& senderNode) {
qCDebug(entities) << "'transfer_status' is 'pending', checking again in 90 seconds..." << entityItemID;
QTimer* transferStatusRetryTimer = new QTimer(this);
connect(transferStatusRetryTimer, &QTimer::timeout, this, [=]() {
validatePop(certID, entityItemID, senderNode, true);
});
transferStatusRetryTimer->setSingleShot(true);
transferStatusRetryTimer->start(90000);
}
QByteArray EntityTree::computeNonce(const QString& certID, const QString ownerKey) { QByteArray EntityTree::computeNonce(const QString& certID, const QString ownerKey) {
QUuid nonce = QUuid::createUuid(); //random, 5-hex value, separated by "-" QUuid nonce = QUuid::createUuid(); //random, 5-hex value, separated by "-"
QByteArray nonceBytes = nonce.toByteArray(); QByteArray nonceBytes = nonce.toByteArray();
@ -1321,7 +1311,7 @@ void EntityTree::sendChallengeOwnershipRequestPacket(const QByteArray& certID, c
nodeList->sendPacket(std::move(challengeOwnershipPacket), *(nodeList->nodeWithUUID(QUuid::fromRfc4122(nodeToChallenge)))); nodeList->sendPacket(std::move(challengeOwnershipPacket), *(nodeList->nodeWithUUID(QUuid::fromRfc4122(nodeToChallenge))));
} }
void EntityTree::validatePop(const QString& certID, const EntityItemID& entityItemID, const SharedNodePointer& senderNode, bool isRetryingValidation) { void EntityTree::validatePop(const QString& certID, const EntityItemID& entityItemID, const SharedNodePointer& senderNode) {
// Start owner verification. // Start owner verification.
auto nodeList = DependencyManager::get<NodeList>(); auto nodeList = DependencyManager::get<NodeList>();
// First, asynchronously hit "proof_of_purchase_status?transaction_type=transfer" endpoint. // First, asynchronously hit "proof_of_purchase_status?transaction_type=transfer" endpoint.
@ -1352,30 +1342,13 @@ void EntityTree::validatePop(const QString& certID, const EntityItemID& entityIt
withWriteLock([&] { withWriteLock([&] {
deleteEntity(entityItemID, true); deleteEntity(entityItemID, true);
}); });
} else if (jsonObject["transfer_status"].toArray().first().toString() == "pending") {
if (isRetryingValidation) {
qCDebug(entities) << "'transfer_status' is 'pending' after retry, deleting entity" << entityItemID;
withWriteLock([&] {
deleteEntity(entityItemID, true);
});
} else {
if (thread() != QThread::currentThread()) {
QMetaObject::invokeMethod(this, "startPendingTransferStatusTimer",
Q_ARG(const QString&, certID),
Q_ARG(const EntityItemID&, entityItemID),
Q_ARG(const SharedNodePointer&, senderNode));
return;
} else {
startPendingTransferStatusTimer(certID, entityItemID, senderNode);
}
}
} else { } else {
// Second, challenge ownership of the PoP cert // Second, challenge ownership of the PoP cert
// (ignore pending status; a failure will be cleaned up during DDV)
sendChallengeOwnershipPacket(certID, sendChallengeOwnershipPacket(certID,
jsonObject["transfer_recipient_key"].toString(), jsonObject["transfer_recipient_key"].toString(),
entityItemID, entityItemID,
senderNode); senderNode);
} }
} else { } else {
qCDebug(entities) << "Call to" << networkReply->url() << "failed with error" << networkReply->error() << "; deleting entity" << entityItemID qCDebug(entities) << "Call to" << networkReply->url() << "failed with error" << networkReply->error() << "; deleting entity" << entityItemID
@ -1619,7 +1592,7 @@ int EntityTree::processEditPacketData(ReceivedMessage& message, const unsigned c
// Delete the entity we just added if it doesn't pass static certificate verification // Delete the entity we just added if it doesn't pass static certificate verification
deleteEntity(entityItemID, true); deleteEntity(entityItemID, true);
} else { } else {
validatePop(properties.getCertificateID(), entityItemID, senderNode, false); validatePop(properties.getCertificateID(), entityItemID, senderNode);
} }
} }

View file

@ -397,12 +397,11 @@ protected:
QHash<EntityItemID, EntityItemPointer> _entitiesToAdd; QHash<EntityItemID, EntityItemPointer> _entitiesToAdd;
Q_INVOKABLE void startChallengeOwnershipTimer(const EntityItemID& entityItemID); Q_INVOKABLE void startChallengeOwnershipTimer(const EntityItemID& entityItemID);
Q_INVOKABLE void startPendingTransferStatusTimer(const QString& certID, const EntityItemID& entityItemID, const SharedNodePointer& senderNode);
private: private:
void sendChallengeOwnershipPacket(const QString& certID, const QString& ownerKey, const EntityItemID& entityItemID, const SharedNodePointer& senderNode); void sendChallengeOwnershipPacket(const QString& certID, const QString& ownerKey, const EntityItemID& entityItemID, const SharedNodePointer& senderNode);
void sendChallengeOwnershipRequestPacket(const QByteArray& certID, const QByteArray& text, const QByteArray& nodeToChallenge, const SharedNodePointer& senderNode); void sendChallengeOwnershipRequestPacket(const QByteArray& certID, const QByteArray& text, const QByteArray& nodeToChallenge, const SharedNodePointer& senderNode);
void validatePop(const QString& certID, const EntityItemID& entityItemID, const SharedNodePointer& senderNode, bool isRetryingValidation); void validatePop(const QString& certID, const EntityItemID& entityItemID, const SharedNodePointer& senderNode);
std::shared_ptr<AvatarData> _myAvatar{ nullptr }; std::shared_ptr<AvatarData> _myAvatar{ nullptr };

View file

@ -557,12 +557,14 @@
} }
if (onWalletScreen) { if (onWalletScreen) {
isWired = true; if (!isWired) {
Users.usernameFromIDReply.connect(usernameFromIDReply); Users.usernameFromIDReply.connect(usernameFromIDReply);
Controller.mousePressEvent.connect(handleMouseEvent); Controller.mousePressEvent.connect(handleMouseEvent);
Controller.mouseMoveEvent.connect(handleMouseMoveEvent); Controller.mouseMoveEvent.connect(handleMouseMoveEvent);
triggerMapping.enable(); triggerMapping.enable();
triggerPressMapping.enable(); triggerPressMapping.enable();
}
isWired = true;
} else { } else {
off(); off();
} }

View file

@ -1055,12 +1055,14 @@ var selectionDisplay = null; // for gridTool.js to ignore
} }
if (onCommerceScreen) { if (onCommerceScreen) {
isWired = true; if (!isWired) {
Users.usernameFromIDReply.connect(usernameFromIDReply); Users.usernameFromIDReply.connect(usernameFromIDReply);
Controller.mousePressEvent.connect(handleMouseEvent); Controller.mousePressEvent.connect(handleMouseEvent);
Controller.mouseMoveEvent.connect(handleMouseMoveEvent); Controller.mouseMoveEvent.connect(handleMouseMoveEvent);
triggerMapping.enable(); triggerMapping.enable();
triggerPressMapping.enable(); triggerPressMapping.enable();
}
isWired = true;
Wallet.refreshWalletStatus(); Wallet.refreshWalletStatus();
} else { } else {
off(); off();