mirror of
https://thingvellir.net/git/overte
synced 2025-03-27 23:52:03 +01:00
handle upload of domain public key to metaverse API
This commit is contained in:
parent
6e4ecffb09
commit
837c4c0810
2 changed files with 15 additions and 3 deletions
|
@ -489,6 +489,10 @@ void DomainServer::setupICEHeartbeatForFullNetworking() {
|
|||
limitedNodeList->startSTUNPublicSocketUpdate();
|
||||
|
||||
// to send ICE heartbeats we'd better have a private key locally with an uploaded public key
|
||||
auto& accountManager = AccountManager::getInstance();
|
||||
if (!accountManager.getAccountInfo().hasPrivateKey()) {
|
||||
accountManager.generateNewDomainKeypair(limitedNodeList->getSessionUUID());
|
||||
}
|
||||
|
||||
if (!_iceHeartbeatTimer) {
|
||||
// setup a timer to heartbeat with the ice-server every so often
|
||||
|
|
|
@ -589,7 +589,7 @@ void AccountManager::requestProfileError(QNetworkReply::NetworkError error) {
|
|||
|
||||
void AccountManager::generateNewKeypair(bool isUserKeypair, const QUuid& domainID) {
|
||||
if (!isUserKeypair && domainID.isNull()) {
|
||||
qWarning() << "AccountManager::generateNewKeypair called for domain keypair with no domain ID. Will not generate keypair.";
|
||||
qCWarning(networking) << "AccountManager::generateNewKeypair called for domain keypair with no domain ID. Will not generate keypair.";
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -633,7 +633,15 @@ void AccountManager::processGeneratedKeypair() {
|
|||
persistAccountToSettings();
|
||||
|
||||
// upload the public key so data-web has an up-to-date key
|
||||
const QString PUBLIC_KEY_UPDATE_PATH = "api/v1/user/public_key";
|
||||
const QString USER_PUBLIC_KEY_UPDATE_PATH = "api/v1/user/public_key";
|
||||
const QString DOMAIN_PUBLIC_KEY_UPDATE_PATH = "api/v1/domains/%1/public_key";
|
||||
|
||||
QString uploadPath;
|
||||
if (keypairGenerator->getDomainID().isNull()) {
|
||||
uploadPath = USER_PUBLIC_KEY_UPDATE_PATH;
|
||||
} else {
|
||||
uploadPath = DOMAIN_PUBLIC_KEY_UPDATE_PATH.arg(uuidStringWithoutCurlyBraces(keypairGenerator->getDomainID()));
|
||||
}
|
||||
|
||||
// setup a multipart upload to send up the public key
|
||||
QHttpMultiPart* requestMultiPart = new QHttpMultiPart(QHttpMultiPart::FormDataType);
|
||||
|
@ -646,7 +654,7 @@ void AccountManager::processGeneratedKeypair() {
|
|||
|
||||
requestMultiPart->append(keyPart);
|
||||
|
||||
sendRequest(PUBLIC_KEY_UPDATE_PATH, AccountManagerAuth::Required, QNetworkAccessManager::PutOperation,
|
||||
sendRequest(uploadPath, AccountManagerAuth::Required, QNetworkAccessManager::PutOperation,
|
||||
JSONCallbackParameters(), QByteArray(), requestMultiPart);
|
||||
|
||||
keypairGenerator->deleteLater();
|
||||
|
|
Loading…
Reference in a new issue