fixed 404, 1100, 1109 - fixed crash app (add server)

This commit is contained in:
dranik
2026-05-18 16:02:51 +03:00
parent b46a9e389f
commit 5eab5fc18b
14 changed files with 438 additions and 78 deletions
@@ -48,7 +48,7 @@ QFuture<QPair<ErrorCode, QJsonArray>> NewsController::fetchNews()
payload.insert(apiDefs::key::serviceType, stacksJson.value(apiDefs::key::serviceType));
}
auto future = gatewayController->postAsync(QString("%1v1/news"), payload);
auto future = gatewayController->postAsync(QString("%1v1/news"), payload, nullptr, gatewayController);
return future.then([gatewayController](QPair<ErrorCode, QByteArray> result) -> QPair<ErrorCode, QJsonArray> {
auto [errorCode, responseBody] = result;
if (errorCode != ErrorCode::NoError) {
@@ -108,6 +108,16 @@ ErrorCode interpretScanQrJson(const QJsonObject &obj)
}
} // namespace
QJsonArray PairingController::gatewayStringMetadataArray(const QString &value)
{
QJsonArray arr;
const QString trimmed = value.trimmed();
if (!trimmed.isEmpty()) {
arr.append(trimmed);
}
return arr;
}
ErrorCode PairingController::parseGenerateQrResponseBody(const QByteArray &responseBody, QrPairingConfigPayload &outPayload)
{
outPayload = QrPairingConfigPayload {};
@@ -193,7 +203,7 @@ QJsonObject PairingController::buildScanQrPayload(const QString &qrUuid, const Q
o[apiDefs::key::installationUuid] = m_appSettingsRepository->getInstallationUuid(true);
o[apiDefs::key::appVersion] = QString(APP_VERSION);
o[apiDefs::key::osVersion] = QSysInfo::productType();
o[apiDefs::key::serviceType] = serviceType;
o[apiDefs::key::userCountryCode] = userCountryCode;
o[apiDefs::key::serviceType] = gatewayStringMetadataArray(serviceType);
o[apiDefs::key::userCountryCode] = gatewayStringMetadataArray(userCountryCode);
return o;
}
@@ -10,7 +10,7 @@
class SecureAppSettingsRepository;
/**
* Core API for QR pairing against Amnezia gateway (POST /api/v1/generate_qr, /api/v1/scan_qr).
* Core API for QR pairing against Amnezia gateway (POST /v1/generate_qr, /v1/scan_qr).
* Phase 1: transport via GatewayController, error mapping incl. gateway `http_status` wrapper and OpenAPI-style bodies.
*/
class PairingController
@@ -38,6 +38,8 @@ public:
static amnezia::ErrorCode validatePairingScanFields(const QString &qrUuid, const QString &vpnConfig, const QString &apiKey,
const QString &serviceType, const QString &userCountryCode);
static QJsonArray gatewayStringMetadataArray(const QString &value);
private:
SecureAppSettingsRepository *m_appSettingsRepository;
};
@@ -1146,7 +1146,7 @@ QFuture<QPair<ErrorCode, QString>> SubscriptionController::getRenewalLink(int se
m_appSettingsRepository->isDevGatewayEnv(isTestPurchase),
apiDefs::requestTimeoutMsecs,
m_appSettingsRepository->isStrictKillSwitchEnabled());
auto postFuture = gatewayController->postAsync(QString("%1v1/renewal_link"), apiPayload);
auto postFuture = gatewayController->postAsync(QString("%1v1/renewal_link"), apiPayload, nullptr, gatewayController);
auto *watcher = new QFutureWatcher<QPair<ErrorCode, QByteArray>>();
QObject::connect(watcher, &QFutureWatcher<QPair<ErrorCode, QByteArray>>::finished,
[promise, watcher, gatewayController]() {