mirror of
https://thingvellir.net/git/overte
synced 2025-03-27 23:52:03 +01:00
Make empty values no longer null, add name property, rename "Hosts" -> "Managers"
This commit is contained in:
parent
c70a041490
commit
b7e4362553
3 changed files with 45 additions and 19 deletions
|
@ -162,6 +162,12 @@
|
|||
"restart": false,
|
||||
"help": "This data will be queryable from your server. It may be collected by High Fidelity and used to share your domain with others.",
|
||||
"settings": [
|
||||
{
|
||||
"name": "world_name",
|
||||
"label": "Name",
|
||||
"advanced": true,
|
||||
"help": "The name of your domain (256 character limit)."
|
||||
},
|
||||
{
|
||||
"name": "description",
|
||||
"label": "Description",
|
||||
|
@ -199,16 +205,16 @@
|
|||
]
|
||||
},
|
||||
{
|
||||
"name": "hosts",
|
||||
"label": "Hosts",
|
||||
"name": "managers",
|
||||
"label": "Server Managers / Administrators",
|
||||
"advanced": true,
|
||||
"type": "table",
|
||||
"can_add_new_rows": true,
|
||||
"help": "Usernames of hosts who can reliably show your domain to new visitors.",
|
||||
"help": "Usernames of managers that administrate the domain.",
|
||||
"numbered": false,
|
||||
"columns": [
|
||||
{
|
||||
"name": "host",
|
||||
"name": "manager",
|
||||
"label": "Username",
|
||||
"can_set": true
|
||||
}
|
||||
|
|
|
@ -34,18 +34,21 @@ const QString DomainMetadata::Users::HOSTNAMES = "user_hostnames";
|
|||
// }
|
||||
|
||||
const QString DomainMetadata::DESCRIPTORS = "descriptors";
|
||||
const QString DomainMetadata::Descriptors::NAME = "world_name";
|
||||
const QString DomainMetadata::Descriptors::DESCRIPTION = "description";
|
||||
const QString DomainMetadata::Descriptors::CAPACITY = "capacity"; // parsed from security
|
||||
const QString DomainMetadata::Descriptors::RESTRICTION = "restriction"; // parsed from ACL
|
||||
const QString DomainMetadata::Descriptors::MATURITY = "maturity";
|
||||
const QString DomainMetadata::Descriptors::HOSTS = "hosts";
|
||||
const QString DomainMetadata::Descriptors::MANAGERS = "managers";
|
||||
const QString DomainMetadata::Descriptors::TAGS = "tags";
|
||||
// descriptors metadata will appear as (JSON):
|
||||
// { "description": String, // capped description
|
||||
// {
|
||||
// "name": String, // capped name
|
||||
// "description": String, // capped description
|
||||
// "capacity": Number,
|
||||
// "restriction": String, // enum of either open, hifi, or acl
|
||||
// "maturity": String, // enum corresponding to ESRB ratings
|
||||
// "hosts": [ String ], // capped list of usernames
|
||||
// "managers": [ String ], // capped list of usernames
|
||||
// "tags": [ String ], // capped list of tags
|
||||
// }
|
||||
|
||||
|
@ -82,12 +85,27 @@ void DomainMetadata::descriptorsChanged() {
|
|||
static const QString DESCRIPTORS_GROUP_KEYPATH = "descriptors";
|
||||
auto descriptorsMap = static_cast<DomainServer*>(parent())->_settingsManager.valueForKeyPath(DESCRIPTORS).toMap();
|
||||
|
||||
// copy simple descriptors (description/maturity)
|
||||
state[Descriptors::DESCRIPTION] = descriptorsMap[Descriptors::DESCRIPTION];
|
||||
state[Descriptors::MATURITY] = descriptorsMap[Descriptors::MATURITY];
|
||||
// copy simple descriptors (name/description/maturity)
|
||||
if (!descriptorsMap[Descriptors::NAME].isNull()) {
|
||||
state[Descriptors::NAME] = descriptorsMap[Descriptors::NAME];
|
||||
} else {
|
||||
state[Descriptors::NAME] = "";
|
||||
}
|
||||
|
||||
// copy array descriptors (hosts/tags)
|
||||
state[Descriptors::HOSTS] = descriptorsMap[Descriptors::HOSTS].toList();
|
||||
if (!descriptorsMap[Descriptors::DESCRIPTION].isNull()) {
|
||||
state[Descriptors::DESCRIPTION] = descriptorsMap[Descriptors::DESCRIPTION];
|
||||
} else {
|
||||
state[Descriptors::DESCRIPTION] = "";
|
||||
}
|
||||
|
||||
if (!descriptorsMap[Descriptors::MATURITY].isNull()) {
|
||||
state[Descriptors::MATURITY] = descriptorsMap[Descriptors::MATURITY];
|
||||
} else {
|
||||
state[Descriptors::MATURITY] = "";
|
||||
}
|
||||
|
||||
// copy array descriptors (managers/tags)
|
||||
state[Descriptors::MANAGERS] = descriptorsMap[Descriptors::MANAGERS].toList();
|
||||
state[Descriptors::TAGS] = descriptorsMap[Descriptors::TAGS].toList();
|
||||
|
||||
// parse capacity
|
||||
|
@ -211,19 +229,20 @@ void DomainMetadata::sendDescriptors() {
|
|||
}
|
||||
|
||||
bool DomainMetadata::handleHTTPRequest(HTTPConnection* connection, const QUrl& url, bool skipSubHandler) {
|
||||
QJsonArray metadataArray;
|
||||
metadataArray << get(DESCRIPTORS);
|
||||
metadataArray << get(USERS);
|
||||
QString domainMetadataJSON = QString("{\"domain\":%1}").arg(QString(QJsonDocument(metadataArray).toJson(QJsonDocument::Compact)));
|
||||
QString domainMetadataJSON = QString("{\"domain\":%1, \"users\":%2}")
|
||||
.arg(QString(QJsonDocument(get(DESCRIPTORS)).toJson(QJsonDocument::Compact)))
|
||||
.arg(QString(QJsonDocument(get(USERS)).toJson(QJsonDocument::Compact)));
|
||||
const QString URI_METADATA = "/metadata";
|
||||
const QString EXPORTER_MIME_TYPE = "application/json";
|
||||
|
||||
qCDebug(domain_metadata_exporter) << "Request on URL " << url;
|
||||
|
||||
if (url.path() == URI_METADATA) {
|
||||
connection->respond(HTTPConnection::StatusCode200, domainMetadataJSON.toUtf8(), qPrintable(EXPORTER_MIME_TYPE));
|
||||
return true;
|
||||
}
|
||||
|
||||
#if DEV_BUILD || PR_BUILD
|
||||
qCDebug(domain_metadata_exporter) << "Metadata request on URL " << url;
|
||||
#endif
|
||||
|
||||
return false;
|
||||
}
|
||||
|
|
|
@ -34,11 +34,12 @@ public:
|
|||
static const QString DESCRIPTORS;
|
||||
class Descriptors {
|
||||
public:
|
||||
static const QString NAME;
|
||||
static const QString DESCRIPTION;
|
||||
static const QString CAPACITY;
|
||||
static const QString RESTRICTION;
|
||||
static const QString MATURITY;
|
||||
static const QString HOSTS;
|
||||
static const QString MANAGERS;
|
||||
static const QString TAGS;
|
||||
};
|
||||
|
||||
|
|
Loading…
Reference in a new issue