From c34cd996dfe7ae8763f900b8d8d5dab23e3afd49 Mon Sep 17 00:00:00 2001 From: Kasen IO Date: Tue, 17 Dec 2019 00:03:59 +0100 Subject: [PATCH] change Metaverse API from setting --- assignment-client/src/avatars/MixerAvatar.cpp | 3 +- .../src/entities/EntityServer.cpp | 1 + domain-server/src/DomainServer.cpp | 9 +++-- ice-server/src/IceServer.cpp | 3 +- interface/src/Application.cpp | 5 ++- interface/src/commerce/Ledger.cpp | 16 ++++++-- interface/src/commerce/QmlCommerce.cpp | 4 +- interface/src/networking/CloseEventSender.cpp | 3 +- interface/src/ui/AddressBarDialog.h | 3 +- .../ui/overlays/ContextOverlayInterface.cpp | 3 +- .../src/RenderableWebEntityItem.cpp | 1 + libraries/entities/src/EntityItem.cpp | 3 +- libraries/entities/src/EntityTree.cpp | 5 ++- .../src/material-networking/TextureCache.cpp | 5 ++- libraries/networking/src/AccountManager.h | 5 ++- libraries/networking/src/AssetUtils.cpp | 1 + libraries/networking/src/DomainHandler.h | 1 + .../networking/src/FileResourceRequest.cpp | 1 + libraries/networking/src/MetaverseAPI.cpp | 38 +++++++++++++++++++ libraries/networking/src/MetaverseAPI.h | 22 +++++++++++ .../networking/src/NetworkingConstants.cpp | 24 ------------ .../networking/src/NetworkingConstants.h | 5 +-- .../src/OAuthNetworkAccessManager.cpp | 3 +- .../procedural/src/procedural/Procedural.cpp | 1 + libraries/qml/src/qml/OffscreenSurface.cpp | 1 + .../script-engine/src/XMLHttpRequestClass.cpp | 5 ++- libraries/ui/src/ui/types/RequestFilters.cpp | 3 +- tools/ac-client/src/ACClientApp.cpp | 3 +- tools/atp-client/src/ATPClientApp.cpp | 3 +- 29 files changed, 123 insertions(+), 57 deletions(-) create mode 100644 libraries/networking/src/MetaverseAPI.cpp create mode 100644 libraries/networking/src/MetaverseAPI.h delete mode 100644 libraries/networking/src/NetworkingConstants.cpp diff --git a/assignment-client/src/avatars/MixerAvatar.cpp b/assignment-client/src/avatars/MixerAvatar.cpp index 5203d25af6..f3d7bb8995 100644 --- a/assignment-client/src/avatars/MixerAvatar.cpp +++ b/assignment-client/src/avatars/MixerAvatar.cpp @@ -22,6 +22,7 @@ #include #include #include +#include #include #include #include "ClientTraitsHandler.h" @@ -235,7 +236,7 @@ void MixerAvatar::requestCurrentOwnership() { QNetworkRequest networkRequest; networkRequest.setAttribute(QNetworkRequest::FollowRedirectsAttribute, true); networkRequest.setHeader(QNetworkRequest::ContentTypeHeader, "application/json"); - QUrl requestURL = NetworkingConstants::METAVERSE_SERVER_URL(); + QUrl requestURL = MetaverseAPI::getCurrentMetaverseServerURL(); requestURL.setPath(POP_MARKETPLACE_API); networkRequest.setUrl(requestURL); diff --git a/assignment-client/src/entities/EntityServer.cpp b/assignment-client/src/entities/EntityServer.cpp index 6bbf4a0e3b..a6ab382781 100644 --- a/assignment-client/src/entities/EntityServer.cpp +++ b/assignment-client/src/entities/EntityServer.cpp @@ -22,6 +22,7 @@ #include #include #include +#include #include #include "../AssignmentDynamicFactory.h" diff --git a/domain-server/src/DomainServer.cpp b/domain-server/src/DomainServer.cpp index ceb4679137..a9bc24c483 100644 --- a/domain-server/src/DomainServer.cpp +++ b/domain-server/src/DomainServer.cpp @@ -38,6 +38,7 @@ #include #include #include +#include #include #include #include @@ -121,7 +122,7 @@ bool DomainServer::forwardMetaverseAPIRequest(HTTPConnection* connection, root.insert(requestSubobjectKey, subobject); QJsonDocument doc { root }; - QUrl url { NetworkingConstants::METAVERSE_SERVER_URL().toString() + metaversePath }; + QUrl url{ MetaverseAPI::getCurrentMetaverseServerURL().toString() + metaversePath }; QNetworkRequest req(url); req.setHeader(QNetworkRequest::UserAgentHeader, HIGH_FIDELITY_USER_AGENT); @@ -516,7 +517,7 @@ bool DomainServer::optionallySetupOAuth() { // if we don't have an oauth provider URL then we default to the default node auth url if (_oauthProviderURL.isEmpty()) { - _oauthProviderURL = NetworkingConstants::METAVERSE_SERVER_URL(); + _oauthProviderURL = MetaverseAPI::getCurrentMetaverseServerURL(); } _oauthClientSecret = QProcessEnvironment::systemEnvironment().value(OAUTH_CLIENT_SECRET_ENV); @@ -2222,7 +2223,7 @@ bool DomainServer::handleHTTPRequest(HTTPConnection* connection, const QUrl& url return true; } else if (url.path() == URI_API_METAVERSE_INFO) { QJsonObject rootJSON { - { "metaverse_url", NetworkingConstants::METAVERSE_SERVER_URL().toString() } + { "metaverse_url", MetaverseAPI::getCurrentMetaverseServerURL().toString() } }; QJsonDocument docJSON{ rootJSON }; @@ -2449,7 +2450,7 @@ bool DomainServer::handleHTTPRequest(HTTPConnection* connection, const QUrl& url QJsonDocument doc(root); - QUrl url { NetworkingConstants::METAVERSE_SERVER_URL().toString() + "/api/v1/places/" + place_id }; + QUrl url { MetaverseAPI::getCurrentMetaverseServerURL().toString() + "/api/v1/places/" + place_id }; url.setQuery("access_token=" + accessTokenVariant.toString()); diff --git a/ice-server/src/IceServer.cpp b/ice-server/src/IceServer.cpp index 6896c7a9c9..2d601048be 100644 --- a/ice-server/src/IceServer.cpp +++ b/ice-server/src/IceServer.cpp @@ -22,6 +22,7 @@ #include #include #include +#include #include #include @@ -209,7 +210,7 @@ void IceServer::requestDomainPublicKey(const QUuid& domainID) { // send a request to the metaverse API for the public key for this domain auto& networkAccessManager = NetworkAccessManager::getInstance(); - QUrl publicKeyURL { NetworkingConstants::METAVERSE_SERVER_URL() }; + QUrl publicKeyURL{ MetaverseAPI::getCurrentMetaverseServerURL() }; QString publicKeyPath = QString("/api/v1/domains/%1/public_key").arg(uuidStringWithoutCurlyBraces(domainID)); publicKeyURL.setPath(publicKeyPath); diff --git a/interface/src/Application.cpp b/interface/src/Application.cpp index 9c60139d06..3eb83afe73 100644 --- a/interface/src/Application.cpp +++ b/interface/src/Application.cpp @@ -111,6 +111,7 @@ #include #include #include +#include #include #include #include @@ -1216,7 +1217,7 @@ Application::Application(int& argc, char** argv, QElapsedTimer& startupTimer, bo // set the account manager's root URL and trigger a login request if we don't have the access token accountManager->setIsAgent(true); - accountManager->setAuthURL(NetworkingConstants::METAVERSE_SERVER_URL()); + accountManager->setAuthURL(MetaverseAPI::getCurrentMetaverseServerURL()); if (!accountManager->hasKeyPair()) { accountManager->generateNewUserKeypair(); } @@ -8466,7 +8467,7 @@ void Application::loadAddAvatarBookmarkDialog() const { void Application::loadAvatarBrowser() const { auto tablet = dynamic_cast(DependencyManager::get()->getTablet("com.highfidelity.interface.tablet.system")); // construct the url to the marketplace item - QString url = NetworkingConstants::METAVERSE_SERVER_URL().toString() + "/marketplace?category=avatars"; + QString url = MetaverseAPI::getCurrentMetaverseServerURL().toString() + "/marketplace?category=avatars"; QString MARKETPLACES_INJECT_SCRIPT_PATH = "file:///" + qApp->applicationDirPath() + "/scripts/system/html/js/marketplacesInject.js"; tablet->gotoWebScreen(url, MARKETPLACES_INJECT_SCRIPT_PATH); diff --git a/interface/src/commerce/Ledger.cpp b/interface/src/commerce/Ledger.cpp index 60fefa5878..4a41374ba3 100644 --- a/interface/src/commerce/Ledger.cpp +++ b/interface/src/commerce/Ledger.cpp @@ -17,6 +17,7 @@ #include #include +#include #include #include "Wallet.h" @@ -181,21 +182,28 @@ QString hfcString(const QJsonValue& sentValue, const QJsonValue& receivedValue) } return result; } -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/"; + +QString getUserPageBaseUrl() { + return MetaverseAPI::getCurrentMetaverseServerURL().toString() + "/users/"; +} + +QString getPlacePageBaseUrl() { + return MetaverseAPI::getCurrentMetaverseServerURL().toString() + "/places/"; +} + static const QStringList KNOWN_USERS(QStringList() << "highfidelity" << "marketplace"); QString userLink(const QString& username, const QString& placename) { if (username.isEmpty()) { if (placename.isEmpty()) { return QString("someone"); } else { - return QString("someone nearby").arg(PLACE_PAGE_BASE_URL, placename); + return QString("someone nearby").arg(getPlacePageBaseUrl(), placename); } } if (KNOWN_USERS.contains(username)) { return username; } - return QString("%2").arg(USER_PAGE_BASE_URL, username); + return QString("%2").arg(getUserPageBaseUrl(), username); } QString transactionString(const QJsonObject& valueObject) { diff --git a/interface/src/commerce/QmlCommerce.cpp b/interface/src/commerce/QmlCommerce.cpp index c8ea044f4b..47105e0f3a 100644 --- a/interface/src/commerce/QmlCommerce.cpp +++ b/interface/src/commerce/QmlCommerce.cpp @@ -72,11 +72,11 @@ void QmlCommerce::openSystemApp(const QString& appName) { else if (appPathIter->contains(".html", Qt::CaseInsensitive)) { QMap::const_iterator injectIter = systemInject.find(appName); if (appPathIter == systemInject.end()) { - tablet->gotoWebScreen(NetworkingConstants::METAVERSE_SERVER_URL().toString() + *appPathIter); + tablet->gotoWebScreen(MetaverseAPI::getCurrentMetaverseServerURL().toString() + *appPathIter); } else { QString inject = "file:///" + qApp->applicationDirPath() + *injectIter; - tablet->gotoWebScreen(NetworkingConstants::METAVERSE_SERVER_URL().toString() + *appPathIter, inject); + tablet->gotoWebScreen(MetaverseAPI::getCurrentMetaverseServerURL().toString() + *appPathIter, inject); } } else { diff --git a/interface/src/networking/CloseEventSender.cpp b/interface/src/networking/CloseEventSender.cpp index 16549d5510..5397c221ad 100644 --- a/interface/src/networking/CloseEventSender.cpp +++ b/interface/src/networking/CloseEventSender.cpp @@ -20,6 +20,7 @@ #include #include #include +#include #include #include #include @@ -28,7 +29,7 @@ QNetworkRequest createNetworkRequest() { QNetworkRequest request; - QUrl requestURL = NetworkingConstants::METAVERSE_SERVER_URL(); + QUrl requestURL = MetaverseAPI::getCurrentMetaverseServerURL(); requestURL.setPath(USER_ACTIVITY_URL); request.setUrl(requestURL); diff --git a/interface/src/ui/AddressBarDialog.h b/interface/src/ui/AddressBarDialog.h index 1254fabbd2..aa3c11e810 100644 --- a/interface/src/ui/AddressBarDialog.h +++ b/interface/src/ui/AddressBarDialog.h @@ -15,6 +15,7 @@ #include #include +#include class AddressBarDialog : public OffscreenQmlDialog { Q_OBJECT @@ -30,7 +31,7 @@ public: bool forwardEnabled() { return _forwardEnabled; } bool useFeed() { return _useFeed; } void setUseFeed(bool useFeed) { if (_useFeed != useFeed) { _useFeed = useFeed; emit useFeedChanged(); } } - QString metaverseServerUrl() { return NetworkingConstants::METAVERSE_SERVER_URL().toString(); } + QString metaverseServerUrl() { return MetaverseAPI::getCurrentMetaverseServerURL().toString(); } signals: void backEnabledChanged(); diff --git a/interface/src/ui/overlays/ContextOverlayInterface.cpp b/interface/src/ui/overlays/ContextOverlayInterface.cpp index 1c8a9019ea..0f1c8978f0 100644 --- a/interface/src/ui/overlays/ContextOverlayInterface.cpp +++ b/interface/src/ui/overlays/ContextOverlayInterface.cpp @@ -14,6 +14,7 @@ #include #include +#include #include #include #include @@ -305,7 +306,7 @@ void ContextOverlayInterface::requestOwnershipVerification(const QUuid& entityID QNetworkRequest networkRequest; networkRequest.setAttribute(QNetworkRequest::FollowRedirectsAttribute, true); networkRequest.setHeader(QNetworkRequest::ContentTypeHeader, "application/json"); - QUrl requestURL = NetworkingConstants::METAVERSE_SERVER_URL(); + QUrl requestURL = MetaverseAPI::getCurrentMetaverseServerURL(); requestURL.setPath("/api/v1/commerce/proof_of_purchase_status/transfer"); QJsonObject request; request["certificate_id"] = entityProperties.getCertificateID(); diff --git a/libraries/entities-renderer/src/RenderableWebEntityItem.cpp b/libraries/entities-renderer/src/RenderableWebEntityItem.cpp index b1feddfd47..1da4999bad 100644 --- a/libraries/entities-renderer/src/RenderableWebEntityItem.cpp +++ b/libraries/entities-renderer/src/RenderableWebEntityItem.cpp @@ -28,6 +28,7 @@ #include "EntitiesRendererLogging.h" #include +#include using namespace render; using namespace render::entities; diff --git a/libraries/entities/src/EntityItem.cpp b/libraries/entities/src/EntityItem.cpp index 598ac17510..fbbfc8b626 100644 --- a/libraries/entities/src/EntityItem.cpp +++ b/libraries/entities/src/EntityItem.cpp @@ -15,6 +15,7 @@ #include #include #include +#include #include #include #include @@ -3207,7 +3208,7 @@ void EntityItem::retrieveMarketplacePublicKey() { QNetworkAccessManager& networkAccessManager = NetworkAccessManager::getInstance(); QNetworkRequest networkRequest; networkRequest.setAttribute(QNetworkRequest::FollowRedirectsAttribute, true); - QUrl requestURL = NetworkingConstants::METAVERSE_SERVER_URL(); + QUrl requestURL = MetaverseAPI::getCurrentMetaverseServerURL(); requestURL.setPath("/api/v1/commerce/marketplace_key"); QJsonObject request; networkRequest.setUrl(requestURL); diff --git a/libraries/entities/src/EntityTree.cpp b/libraries/entities/src/EntityTree.cpp index 6c12c6d019..a7416eac79 100644 --- a/libraries/entities/src/EntityTree.cpp +++ b/libraries/entities/src/EntityTree.cpp @@ -16,6 +16,7 @@ #include #include #include +#include #include "AccountManager.h" #include #include @@ -1464,7 +1465,7 @@ void EntityTree::startDynamicDomainVerificationOnServer(float minimumAgeToRemove QNetworkRequest networkRequest; networkRequest.setAttribute(QNetworkRequest::FollowRedirectsAttribute, true); networkRequest.setHeader(QNetworkRequest::ContentTypeHeader, "application/json"); - QUrl requestURL = NetworkingConstants::METAVERSE_SERVER_URL(); + QUrl requestURL = MetaverseAPI::getCurrentMetaverseServerURL(); requestURL.setPath("/api/v1/commerce/proof_of_purchase_status/location"); QJsonObject request; request["certificate_id"] = certificateID; @@ -1687,7 +1688,7 @@ void EntityTree::validatePop(const QString& certID, const EntityItemID& entityIt QNetworkRequest networkRequest; networkRequest.setAttribute(QNetworkRequest::FollowRedirectsAttribute, true); networkRequest.setHeader(QNetworkRequest::ContentTypeHeader, "application/json"); - QUrl requestURL = NetworkingConstants::METAVERSE_SERVER_URL(); + QUrl requestURL = MetaverseAPI::getCurrentMetaverseServerURL(); requestURL.setPath("/api/v1/commerce/proof_of_purchase_status/transfer"); QJsonObject request; request["certificate_id"] = certID; diff --git a/libraries/material-networking/src/material-networking/TextureCache.cpp b/libraries/material-networking/src/material-networking/TextureCache.cpp index 8ffcad0c69..4831223fe9 100644 --- a/libraries/material-networking/src/material-networking/TextureCache.cpp +++ b/libraries/material-networking/src/material-networking/TextureCache.cpp @@ -43,9 +43,10 @@ #include #include -#include "NetworkLogging.h" +#include #include "MaterialNetworkingLogging.h" -#include "NetworkingConstants.h" +#include +#include #include #include diff --git a/libraries/networking/src/AccountManager.h b/libraries/networking/src/AccountManager.h index 2e94ccf0ea..37cb548b7e 100644 --- a/libraries/networking/src/AccountManager.h +++ b/libraries/networking/src/AccountManager.h @@ -24,8 +24,9 @@ #include "AccountSettings.h" #include "DataServerAccountInfo.h" #include "NetworkingConstants.h" +#include "MetaverseAPI.h" #include "NetworkAccessManager.h" -#include "SharedUtil.h" +#include class JSONCallbackParameters { public: @@ -97,7 +98,7 @@ public: void setTemporaryDomain(const QUuid& domainID, const QString& key); const QString& getTemporaryDomainKey(const QUuid& domainID) { return _accountInfo.getTemporaryDomainKey(domainID); } - QUrl getMetaverseServerURL() { return NetworkingConstants::METAVERSE_SERVER_URL(); } + QUrl getMetaverseServerURL() { return MetaverseAPI::getCurrentMetaverseServerURL(); } void removeAccountFromFile(); diff --git a/libraries/networking/src/AssetUtils.cpp b/libraries/networking/src/AssetUtils.cpp index 6fb914a8b2..b0eb19bb73 100644 --- a/libraries/networking/src/AssetUtils.cpp +++ b/libraries/networking/src/AssetUtils.cpp @@ -21,6 +21,7 @@ #include "NetworkAccessManager.h" #include "NetworkLogging.h" #include "NetworkingConstants.h" +#include "MetaverseAPI.h" #include "ResourceManager.h" diff --git a/libraries/networking/src/DomainHandler.h b/libraries/networking/src/DomainHandler.h index fb18866001..27dd7cd95d 100644 --- a/libraries/networking/src/DomainHandler.h +++ b/libraries/networking/src/DomainHandler.h @@ -29,6 +29,7 @@ #include "Node.h" #include "ReceivedMessage.h" #include "NetworkingConstants.h" +#include "MetaverseAPI.h" const unsigned short DEFAULT_DOMAIN_SERVER_PORT = 40102; const unsigned short DEFAULT_DOMAIN_SERVER_DTLS_PORT = 40103; diff --git a/libraries/networking/src/FileResourceRequest.cpp b/libraries/networking/src/FileResourceRequest.cpp index 11489f13bd..f9ec7797be 100644 --- a/libraries/networking/src/FileResourceRequest.cpp +++ b/libraries/networking/src/FileResourceRequest.cpp @@ -22,6 +22,7 @@ #include "NetworkLogging.h" #include "ResourceManager.h" #include "NetworkingConstants.h" +#include "MetaverseAPI.h" void FileResourceRequest::doSend() { auto statTracker = DependencyManager::get(); diff --git a/libraries/networking/src/MetaverseAPI.cpp b/libraries/networking/src/MetaverseAPI.cpp new file mode 100644 index 0000000000..0fb0bcecad --- /dev/null +++ b/libraries/networking/src/MetaverseAPI.cpp @@ -0,0 +1,38 @@ +// +// MetaverseAPI.cpp +// libraries/networking/src +// +// Created by Kalila (kasenvr) on 2019-12-16. +// Copyright 2019 Project Athena +// +// Distributed under the Apache License, Version 2.0. +// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html +// + +#include "MetaverseAPI.h" + +#include +#include +#include "NetworkingConstants.h" +#include + + +namespace MetaverseAPI { + // You can change the return of this function if you want to use a custom metaverse URL at compile time + // or you can pass a custom URL via the env variable + QUrl getCurrentMetaverseServerURL() { + QUrl selectedMetaverseURL; + Setting::Handle selectedMetaverseURLSetting("private/selectedMetaverseURL", + NetworkingConstants::METAVERSE_SERVER_URL_STABLE); + + selectedMetaverseURL = selectedMetaverseURLSetting.get(); + + const QString HIFI_METAVERSE_URL_ENV = "HIFI_METAVERSE_URL"; + + if (QProcessEnvironment::systemEnvironment().contains(HIFI_METAVERSE_URL_ENV)) { + return QUrl(QProcessEnvironment::systemEnvironment().value(HIFI_METAVERSE_URL_ENV)); + } + + return selectedMetaverseURL; + }; +} diff --git a/libraries/networking/src/MetaverseAPI.h b/libraries/networking/src/MetaverseAPI.h new file mode 100644 index 0000000000..423f465229 --- /dev/null +++ b/libraries/networking/src/MetaverseAPI.h @@ -0,0 +1,22 @@ +// +// MetaverseAPI.h +// libraries/networking/src +// +// Created by Kalila (kasenvr) on 2019-12-16. +// Copyright 2019 Project Athena +// +// Distributed under the Apache License, Version 2.0. +// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html +// + +#ifndef athena_MetaverseAPI_h +#define athena_MetaverseAPI_h + +#include +#include + +namespace MetaverseAPI { + QUrl getCurrentMetaverseServerURL(); +} + +#endif // athena_MetaverseAPI_h diff --git a/libraries/networking/src/NetworkingConstants.cpp b/libraries/networking/src/NetworkingConstants.cpp deleted file mode 100644 index 622c307efa..0000000000 --- a/libraries/networking/src/NetworkingConstants.cpp +++ /dev/null @@ -1,24 +0,0 @@ -// -// NetworkingConstants.cpp -// libraries/networking/src -// -// Created by Seth Alves on 2018-2-28. -// Copyright 2018 High Fidelity, Inc. -// -// Distributed under the Apache License, Version 2.0. -// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html -// - -#include "NetworkingConstants.h" - -namespace NetworkingConstants { - // You can change the return of this function if you want to use a custom metaverse URL at compile time - // or you can pass a custom URL via the env variable - QUrl METAVERSE_SERVER_URL() { - const QString HIFI_METAVERSE_URL_ENV = "HIFI_METAVERSE_URL"; - const QUrl serverURL = QProcessEnvironment::systemEnvironment().contains(HIFI_METAVERSE_URL_ENV) - ? QUrl(QProcessEnvironment::systemEnvironment().value(HIFI_METAVERSE_URL_ENV)) - : METAVERSE_SERVER_URL_STABLE; - return serverURL; - }; -} diff --git a/libraries/networking/src/NetworkingConstants.h b/libraries/networking/src/NetworkingConstants.h index 117a41c976..d5dae658c9 100644 --- a/libraries/networking/src/NetworkingConstants.h +++ b/libraries/networking/src/NetworkingConstants.h @@ -25,9 +25,8 @@ namespace NetworkingConstants { // if you manually generate a personal access token for the domains scope // at https://staging.highfidelity.com/user/tokens/new?for_domain_server=true - const QUrl METAVERSE_SERVER_URL_STABLE { "https://metaverse.highfidelity.com" }; - const QUrl METAVERSE_SERVER_URL_STAGING { "https://staging.highfidelity.com" }; - QUrl METAVERSE_SERVER_URL(); + const QUrl METAVERSE_SERVER_URL_STABLE { "https://metaverse.projectathena.io" }; + const QUrl METAVERSE_SERVER_URL_STAGING { "https://staging.projectathena.io" }; } const QString HIFI_URL_SCHEME_ABOUT = "about"; diff --git a/libraries/networking/src/OAuthNetworkAccessManager.cpp b/libraries/networking/src/OAuthNetworkAccessManager.cpp index 272ff47a49..b1e04da4b6 100644 --- a/libraries/networking/src/OAuthNetworkAccessManager.cpp +++ b/libraries/networking/src/OAuthNetworkAccessManager.cpp @@ -18,6 +18,7 @@ #include "AccountManager.h" #include "LimitedNodeList.h" #include "NetworkingConstants.h" +#include "MetaverseAPI.h" #include "SharedUtil.h" QThreadStorage oauthNetworkAccessManagers; @@ -35,7 +36,7 @@ QNetworkReply* OAuthNetworkAccessManager::createRequest(QNetworkAccessManager::O auto accountManager = DependencyManager::get(); if (accountManager->hasValidAccessToken() - && req.url().host() == NetworkingConstants::METAVERSE_SERVER_URL().host()) { + && req.url().host() == MetaverseAPI::getCurrentMetaverseServerURL().host()) { QNetworkRequest authenticatedRequest(req); authenticatedRequest.setAttribute(QNetworkRequest::FollowRedirectsAttribute, true); authenticatedRequest.setHeader(QNetworkRequest::UserAgentHeader, HIGH_FIDELITY_USER_AGENT); diff --git a/libraries/procedural/src/procedural/Procedural.cpp b/libraries/procedural/src/procedural/Procedural.cpp index 43c6b25dcb..10f46f8efd 100644 --- a/libraries/procedural/src/procedural/Procedural.cpp +++ b/libraries/procedural/src/procedural/Procedural.cpp @@ -20,6 +20,7 @@ #include #include #include +#include #include #include "ShaderConstants.h" diff --git a/libraries/qml/src/qml/OffscreenSurface.cpp b/libraries/qml/src/qml/OffscreenSurface.cpp index d9fc8117bd..2678cb5591 100644 --- a/libraries/qml/src/qml/OffscreenSurface.cpp +++ b/libraries/qml/src/qml/OffscreenSurface.cpp @@ -24,6 +24,7 @@ #include #include #include +#include #include "Logging.h" #include "impl/SharedObject.h" diff --git a/libraries/script-engine/src/XMLHttpRequestClass.cpp b/libraries/script-engine/src/XMLHttpRequestClass.cpp index 571c0e2a0e..e62726f5d0 100644 --- a/libraries/script-engine/src/XMLHttpRequestClass.cpp +++ b/libraries/script-engine/src/XMLHttpRequestClass.cpp @@ -20,12 +20,11 @@ #include #include #include +#include #include "ResourceRequestObserver.h" #include "ScriptEngine.h" -const QString METAVERSE_API_URL = NetworkingConstants::METAVERSE_SERVER_URL().toString() + "/api/"; - Q_DECLARE_METATYPE(QByteArray*) XMLHttpRequestClass::XMLHttpRequestClass(QScriptEngine* engine) : @@ -126,6 +125,8 @@ void XMLHttpRequestClass::open(const QString& method, const QString& url, bool a _url.setUrl(url); _async = async; + const QString METAVERSE_API_URL = MetaverseAPI::getCurrentMetaverseServerURL().toString() + "/api/"; + if (url.toLower().left(METAVERSE_API_URL.length()) == METAVERSE_API_URL) { auto accountManager = DependencyManager::get(); diff --git a/libraries/ui/src/ui/types/RequestFilters.cpp b/libraries/ui/src/ui/types/RequestFilters.cpp index 3fa1cd0bd9..14fcc7a781 100644 --- a/libraries/ui/src/ui/types/RequestFilters.cpp +++ b/libraries/ui/src/ui/types/RequestFilters.cpp @@ -16,6 +16,7 @@ #include #include +#include #include #include "ContextAwareProfile.h" @@ -25,7 +26,7 @@ namespace { bool isAuthableHighFidelityURL(const QUrl& url) { - auto metaverseServerURL = NetworkingConstants::METAVERSE_SERVER_URL(); + auto metaverseServerURL = MetaverseAPI::getCurrentMetaverseServerURL(); static const QStringList HF_HOSTS = { "highfidelity.com", "highfidelity.io", metaverseServerURL.toString(), "metaverse.highfidelity.io" diff --git a/tools/ac-client/src/ACClientApp.cpp b/tools/ac-client/src/ACClientApp.cpp index 24805a3348..3b5db1a1b1 100644 --- a/tools/ac-client/src/ACClientApp.cpp +++ b/tools/ac-client/src/ACClientApp.cpp @@ -18,6 +18,7 @@ #include #include +#include #include #include #include @@ -106,7 +107,7 @@ ACClientApp::ACClientApp(int argc, char* argv[]) : auto accountManager = DependencyManager::get(); accountManager->setIsAgent(true); - accountManager->setAuthURL(NetworkingConstants::METAVERSE_SERVER_URL()); + accountManager->setAuthURL(MetaverseAPI::getCurrentMetaverseServerURL()); auto nodeList = DependencyManager::get(); diff --git a/tools/atp-client/src/ATPClientApp.cpp b/tools/atp-client/src/ATPClientApp.cpp index b2e7db5c87..09fcf38dff 100644 --- a/tools/atp-client/src/ATPClientApp.cpp +++ b/tools/atp-client/src/ATPClientApp.cpp @@ -20,6 +20,7 @@ #include #include +#include #include #include #include @@ -144,7 +145,7 @@ ATPClientApp::ATPClientApp(int argc, char* argv[]) : auto accountManager = DependencyManager::get(); accountManager->setIsAgent(true); - accountManager->setAuthURL(NetworkingConstants::METAVERSE_SERVER_URL()); + accountManager->setAuthURL(MetaverseAPI::getCurrentMetaverseServerURL()); auto nodeList = DependencyManager::get();