mirror of
https://github.com/overte-org/overte.git
synced 2025-08-08 21:57:00 +02:00
Merge pull request #12207 from davidkelly/dk/placesInHfcTransferHistory
nearby hfc transfers should send the location
This commit is contained in:
commit
2e4fc5e58c
2 changed files with 16 additions and 10 deletions
|
@ -392,7 +392,6 @@ Item {
|
||||||
width: 118;
|
width: 118;
|
||||||
height: paintedHeight;
|
height: paintedHeight;
|
||||||
wrapMode: Text.WordWrap;
|
wrapMode: Text.WordWrap;
|
||||||
font.bold: true;
|
|
||||||
// Alignment
|
// Alignment
|
||||||
horizontalAlignment: Text.AlignRight;
|
horizontalAlignment: Text.AlignRight;
|
||||||
}
|
}
|
||||||
|
|
|
@ -17,6 +17,7 @@
|
||||||
#include "Ledger.h"
|
#include "Ledger.h"
|
||||||
#include "CommerceLogging.h"
|
#include "CommerceLogging.h"
|
||||||
#include <NetworkingConstants.h>
|
#include <NetworkingConstants.h>
|
||||||
|
#include <AddressManager.h>
|
||||||
|
|
||||||
// inventory answers {status: 'success', data: {assets: [{id: "guid", title: "name", preview: "url"}....]}}
|
// inventory answers {status: 'success', data: {assets: [{id: "guid", title: "name", preview: "url"}....]}}
|
||||||
// balance answers {status: 'success', data: {balance: integer}}
|
// balance answers {status: 'success', data: {balance: integer}}
|
||||||
|
@ -122,25 +123,30 @@ QString hfcString(const QJsonValue& sentValue, const QJsonValue& receivedValue)
|
||||||
int sent = sentValue.toInt();
|
int sent = sentValue.toInt();
|
||||||
int received = receivedValue.toInt();
|
int received = receivedValue.toInt();
|
||||||
if (sent <= 0 && received <= 0) {
|
if (sent <= 0 && received <= 0) {
|
||||||
return QString("-");
|
return QString("0 HFC");
|
||||||
}
|
}
|
||||||
QString result;
|
QString result;
|
||||||
if (sent > 0) {
|
if (sent > 0) {
|
||||||
result += QString("<font color='#B70A37'>-%1 HFC</font>").arg(sent);
|
result += QString("<font color='#B70A37'><b>-%1 HFC</b></font>").arg(sent);
|
||||||
if (received > 0) {
|
if (received > 0) {
|
||||||
result += QString("<br>");
|
result += QString("<br>");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (received > 0) {
|
if (received > 0) {
|
||||||
result += QString("<font color='#3AA38F'>%1 HFC</font>").arg(received);
|
result += QString("<font color='#3AA38F'><b>%1 HFC</b></font>").arg(received);
|
||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
static const QString USER_PAGE_BASE_URL = NetworkingConstants::METAVERSE_SERVER_URL().toString() + "/users/";
|
static const QString USER_PAGE_BASE_URL = NetworkingConstants::METAVERSE_SERVER_URL().toString() + "/users/";
|
||||||
|
static const QString PLACE_PAGE_BASE_URL = NetworkingConstants::METAVERSE_SERVER_URL().toString() + "/places/";
|
||||||
static const QStringList KNOWN_USERS(QStringList() << "highfidelity" << "marketplace");
|
static const QStringList KNOWN_USERS(QStringList() << "highfidelity" << "marketplace");
|
||||||
QString userLink(const QString& username) {
|
QString userLink(const QString& username, const QString& placename) {
|
||||||
if (username.isEmpty()) {
|
if (username.isEmpty()) {
|
||||||
return QString("someone");
|
if (placename.isEmpty()) {
|
||||||
|
return QString("someone");
|
||||||
|
} else {
|
||||||
|
return QString("someone <a href=\"%1%2\">nearby</a>").arg(PLACE_PAGE_BASE_URL, placename);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if (KNOWN_USERS.contains(username)) {
|
if (KNOWN_USERS.contains(username)) {
|
||||||
return username;
|
return username;
|
||||||
|
@ -157,13 +163,13 @@ QString transactionString(const QJsonObject& valueObject) {
|
||||||
QDateTime createdAt(QDateTime::fromSecsSinceEpoch(dateInteger, Qt::UTC));
|
QDateTime createdAt(QDateTime::fromSecsSinceEpoch(dateInteger, Qt::UTC));
|
||||||
QString result;
|
QString result;
|
||||||
|
|
||||||
if (sentCerts <= 0 && receivedCerts <= 0) {
|
if (sentCerts <= 0 && receivedCerts <= 0 && !KNOWN_USERS.contains(valueObject["sender_name"].toString())) {
|
||||||
// this is an hfc transfer.
|
// this is an hfc transfer.
|
||||||
if (sent > 0) {
|
if (sent > 0) {
|
||||||
QString recipient = userLink(valueObject["recipient_name"].toString());
|
QString recipient = userLink(valueObject["recipient_name"].toString(), valueObject["place_name"].toString());
|
||||||
result += QString("Money sent to %1").arg(recipient);
|
result += QString("Money sent to %1").arg(recipient);
|
||||||
} else {
|
} else {
|
||||||
QString sender = userLink(valueObject["sender_name"].toString());
|
QString sender = userLink(valueObject["sender_name"].toString(), valueObject["place_name"].toString());
|
||||||
result += QString("Money from %1").arg(sender);
|
result += QString("Money from %1").arg(sender);
|
||||||
}
|
}
|
||||||
if (!message.isEmpty()) {
|
if (!message.isEmpty()) {
|
||||||
|
@ -172,8 +178,8 @@ QString transactionString(const QJsonObject& valueObject) {
|
||||||
} else {
|
} else {
|
||||||
result += valueObject["message"].toString();
|
result += valueObject["message"].toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
// no matter what we append a smaller date to the bottom of this...
|
// no matter what we append a smaller date to the bottom of this...
|
||||||
|
|
||||||
result += QString("<br><font size='-2' color='#1080B8'>%1").arg(createdAt.toLocalTime().toString(Qt::DefaultLocaleShortDate));
|
result += QString("<br><font size='-2' color='#1080B8'>%1").arg(createdAt.toLocalTime().toString(Qt::DefaultLocaleShortDate));
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
@ -314,6 +320,7 @@ void Ledger::transferHfcToNode(const QString& hfc_key, const QString& nodeID, co
|
||||||
transaction["node_id"] = nodeID;
|
transaction["node_id"] = nodeID;
|
||||||
transaction["quantity"] = amount;
|
transaction["quantity"] = amount;
|
||||||
transaction["message"] = optionalMessage;
|
transaction["message"] = optionalMessage;
|
||||||
|
transaction["place_name"] = DependencyManager::get<AddressManager>()->getPlaceName();
|
||||||
QJsonDocument transactionDoc{ transaction };
|
QJsonDocument transactionDoc{ transaction };
|
||||||
auto transactionString = transactionDoc.toJson(QJsonDocument::Compact);
|
auto transactionString = transactionDoc.toJson(QJsonDocument::Compact);
|
||||||
signedSend("transaction", transactionString, hfc_key, "transfer_hfc_to_node", "transferHfcToNodeSuccess", "transferHfcToNodeFailure");
|
signedSend("transaction", transactionString, hfc_key, "transfer_hfc_to_node", "transferHfcToNodeSuccess", "transferHfcToNodeFailure");
|
||||||
|
|
Loading…
Reference in a new issue