added installation_uuid to apiPayload (#747)

Added installation_uuid to apiPayload
This commit is contained in:
Nethius 2024-04-18 20:02:34 +07:00 committed by GitHub
parent f0085f52eb
commit d50e7dd3f4
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
8 changed files with 38 additions and 10 deletions

View file

@ -5,7 +5,6 @@
#include <QNetworkReply>
#include <QtConcurrent>
#include "core/errorstrings.h"
#include "configurators/wireguard_configurator.h"
namespace
@ -20,6 +19,7 @@ namespace
constexpr char certificate[] = "certificate";
constexpr char publicKey[] = "public_key";
constexpr char protocol[] = "protocol";
constexpr char uuid[] = "installation_uuid";
}
}
@ -64,11 +64,11 @@ QJsonObject ApiController::fillApiPayload(const QString &protocol, const ApiCont
return obj;
}
ErrorCode ApiController::updateServerConfigFromApi(QJsonObject &serverConfig)
ErrorCode ApiController::updateServerConfigFromApi(const QString &installationUuid, QJsonObject &serverConfig)
{
QFutureWatcher<ErrorCode> watcher;
QFuture<ErrorCode> future = QtConcurrent::run([this, &serverConfig]() {
QFuture<ErrorCode> future = QtConcurrent::run([this, &serverConfig, &installationUuid]() {
auto containerConfig = serverConfig.value(config_key::containers).toArray();
if (serverConfig.value(config_key::configVersion).toInt()) {
@ -86,7 +86,10 @@ ErrorCode ApiController::updateServerConfigFromApi(QJsonObject &serverConfig)
auto apiPayloadData = generateApiPayloadData(protocol);
QByteArray requestBody = QJsonDocument(fillApiPayload(protocol, apiPayloadData)).toJson();
auto apiPayload = fillApiPayload(protocol, apiPayloadData);
apiPayload[configKey::uuid] = installationUuid;
QByteArray requestBody = QJsonDocument(apiPayload).toJson();
QScopedPointer<QNetworkReply> reply;
reply.reset(manager.post(request, requestBody));

View file

@ -13,7 +13,7 @@ public:
explicit ApiController(QObject *parent = nullptr);
public slots:
ErrorCode updateServerConfigFromApi(QJsonObject &serverConfig);
ErrorCode updateServerConfigFromApi(const QString &installationUuid, QJsonObject &serverConfig);
private:
struct ApiPayloadData {