feature: retrieving support info from gateway (#1483)
* feature: retrieving support info from gateway * feature: added "external-premium" service-type * chore: fixed external premium visability
This commit is contained in:
parent
68db721089
commit
7fd71a8408
8 changed files with 67 additions and 21 deletions
|
@ -10,7 +10,8 @@ namespace apiDefs
|
||||||
AmneziaFreeV3,
|
AmneziaFreeV3,
|
||||||
AmneziaPremiumV1,
|
AmneziaPremiumV1,
|
||||||
AmneziaPremiumV2,
|
AmneziaPremiumV2,
|
||||||
SelfHosted
|
SelfHosted,
|
||||||
|
ExternalPremium
|
||||||
};
|
};
|
||||||
|
|
||||||
enum ConfigSource {
|
enum ConfigSource {
|
||||||
|
@ -43,6 +44,13 @@ namespace apiDefs
|
||||||
constexpr QLatin1String maxDeviceCount("max_device_count");
|
constexpr QLatin1String maxDeviceCount("max_device_count");
|
||||||
constexpr QLatin1String subscriptionEndDate("subscription_end_date");
|
constexpr QLatin1String subscriptionEndDate("subscription_end_date");
|
||||||
constexpr QLatin1String issuedConfigs("issued_configs");
|
constexpr QLatin1String issuedConfigs("issued_configs");
|
||||||
|
|
||||||
|
constexpr QLatin1String supportInfo("support_info");
|
||||||
|
constexpr QLatin1String email("email");
|
||||||
|
constexpr QLatin1String billingEmail("billing_email");
|
||||||
|
constexpr QLatin1String website("website");
|
||||||
|
constexpr QLatin1String websiteName("website_name");
|
||||||
|
constexpr QLatin1String telegram("telegram");
|
||||||
}
|
}
|
||||||
|
|
||||||
const int requestTimeoutMsecs = 12 * 1000; // 12 secs
|
const int requestTimeoutMsecs = 12 * 1000; // 12 secs
|
||||||
|
|
|
@ -32,15 +32,17 @@ apiDefs::ConfigType apiUtils::getConfigType(const QJsonObject &serverConfigObjec
|
||||||
|
|
||||||
constexpr QLatin1String servicePremium("amnezia-premium");
|
constexpr QLatin1String servicePremium("amnezia-premium");
|
||||||
constexpr QLatin1String serviceFree("amnezia-free");
|
constexpr QLatin1String serviceFree("amnezia-free");
|
||||||
|
constexpr QLatin1String serviceExternalPremium("external-premium");
|
||||||
|
|
||||||
auto apiConfigObject = serverConfigObject.value(apiDefs::key::apiConfig).toObject();
|
auto apiConfigObject = serverConfigObject.value(apiDefs::key::apiConfig).toObject();
|
||||||
auto stackType = apiConfigObject.value(apiDefs::key::stackType).toString();
|
|
||||||
auto serviceType = apiConfigObject.value(apiDefs::key::serviceType).toString();
|
auto serviceType = apiConfigObject.value(apiDefs::key::serviceType).toString();
|
||||||
|
|
||||||
if (serviceType == servicePremium || stackType == stackPremium) {
|
if (serviceType == servicePremium) {
|
||||||
return apiDefs::ConfigType::AmneziaPremiumV2;
|
return apiDefs::ConfigType::AmneziaPremiumV2;
|
||||||
} else if (serviceType == serviceFree || stackType == stackFree) {
|
} else if (serviceType == serviceFree) {
|
||||||
return apiDefs::ConfigType::AmneziaFreeV3;
|
return apiDefs::ConfigType::AmneziaFreeV3;
|
||||||
|
} else if (serviceType == serviceExternalPremium) {
|
||||||
|
return apiDefs::ConfigType::ExternalPremium;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
default: {
|
default: {
|
||||||
|
@ -86,3 +88,10 @@ amnezia::ErrorCode apiUtils::checkNetworkReplyErrors(const QList<QSslError> &ssl
|
||||||
qDebug() << "something went wrong";
|
qDebug() << "something went wrong";
|
||||||
return amnezia::ErrorCode::InternalError;
|
return amnezia::ErrorCode::InternalError;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool apiUtils::isPremiumServer(const QJsonObject &serverConfigObject)
|
||||||
|
{
|
||||||
|
static const QSet<apiDefs::ConfigType> premiumTypes = { apiDefs::ConfigType::AmneziaPremiumV1, apiDefs::ConfigType::AmneziaPremiumV2,
|
||||||
|
apiDefs::ConfigType::ExternalPremium };
|
||||||
|
return premiumTypes.contains(getConfigType(serverConfigObject));
|
||||||
|
}
|
||||||
|
|
|
@ -13,6 +13,8 @@ namespace apiUtils
|
||||||
|
|
||||||
bool isSubscriptionExpired(const QString &subscriptionEndDate);
|
bool isSubscriptionExpired(const QString &subscriptionEndDate);
|
||||||
|
|
||||||
|
bool isPremiumServer(const QJsonObject &serverConfigObject);
|
||||||
|
|
||||||
apiDefs::ConfigType getConfigType(const QJsonObject &serverConfigObject);
|
apiDefs::ConfigType getConfigType(const QJsonObject &serverConfigObject);
|
||||||
apiDefs::ConfigSource getConfigSource(const QJsonObject &serverConfigObject);
|
apiDefs::ConfigSource getConfigSource(const QJsonObject &serverConfigObject);
|
||||||
|
|
||||||
|
|
|
@ -310,7 +310,7 @@ bool ApiConfigsController::deactivateDevice()
|
||||||
auto serverConfigObject = m_serversModel->getServerConfig(serverIndex);
|
auto serverConfigObject = m_serversModel->getServerConfig(serverIndex);
|
||||||
auto apiConfigObject = serverConfigObject.value(configKey::apiConfig).toObject();
|
auto apiConfigObject = serverConfigObject.value(configKey::apiConfig).toObject();
|
||||||
|
|
||||||
if (apiUtils::getConfigType(serverConfigObject) != apiDefs::ConfigType::AmneziaPremiumV2) {
|
if (!apiUtils::isPremiumServer(serverConfigObject)) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -345,7 +345,7 @@ bool ApiConfigsController::deactivateExternalDevice(const QString &uuid, const Q
|
||||||
auto serverConfigObject = m_serversModel->getServerConfig(serverIndex);
|
auto serverConfigObject = m_serversModel->getServerConfig(serverIndex);
|
||||||
auto apiConfigObject = serverConfigObject.value(configKey::apiConfig).toObject();
|
auto apiConfigObject = serverConfigObject.value(configKey::apiConfig).toObject();
|
||||||
|
|
||||||
if (apiUtils::getConfigType(serverConfigObject) != apiDefs::ConfigType::AmneziaPremiumV2) {
|
if (!apiUtils::isPremiumServer(serverConfigObject)) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -62,7 +62,7 @@ bool ApiSettingsController::getAccountInfo(bool reload)
|
||||||
|
|
||||||
QByteArray responseBody;
|
QByteArray responseBody;
|
||||||
|
|
||||||
if (apiUtils::getConfigType(serverConfig) == apiDefs::ConfigType::AmneziaPremiumV2) {
|
if (apiUtils::isPremiumServer(serverConfig)) {
|
||||||
ErrorCode errorCode = gatewayController.post(QString("%1v1/account_info"), apiPayload, responseBody);
|
ErrorCode errorCode = gatewayController.post(QString("%1v1/account_info"), apiPayload, responseBody);
|
||||||
if (errorCode != ErrorCode::NoError) {
|
if (errorCode != ErrorCode::NoError) {
|
||||||
emit errorOccurred(errorCode);
|
emit errorOccurred(errorCode);
|
||||||
|
|
|
@ -48,15 +48,19 @@ QVariant ApiAccountInfoModel::data(const QModelIndex &index, int role) const
|
||||||
}
|
}
|
||||||
case ServiceDescriptionRole: {
|
case ServiceDescriptionRole: {
|
||||||
if (m_accountInfoData.configType == apiDefs::ConfigType::AmneziaPremiumV2) {
|
if (m_accountInfoData.configType == apiDefs::ConfigType::AmneziaPremiumV2) {
|
||||||
return tr("Classic VPN for seamless work, downloading large files, and watching videos. Access all websites and online resources. "
|
return tr("Classic VPN for seamless work, downloading large files, and watching videos. Access all websites and online "
|
||||||
|
"resources. "
|
||||||
"Speeds up to 200 Mbps");
|
"Speeds up to 200 Mbps");
|
||||||
} else if (m_accountInfoData.configType == apiDefs::ConfigType::AmneziaFreeV3) {
|
} else if (m_accountInfoData.configType == apiDefs::ConfigType::AmneziaFreeV3) {
|
||||||
return tr("Free unlimited access to a basic set of websites such as Facebook, Instagram, Twitter (X), Discord, Telegram and "
|
return tr("Free unlimited access to a basic set of websites such as Facebook, Instagram, Twitter (X), Discord, Telegram and "
|
||||||
"more. YouTube is not included in the free plan.");
|
"more. YouTube is not included in the free plan.");
|
||||||
|
} else {
|
||||||
|
return "";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
case IsComponentVisibleRole: {
|
case IsComponentVisibleRole: {
|
||||||
return m_accountInfoData.configType == apiDefs::ConfigType::AmneziaPremiumV2;
|
return m_accountInfoData.configType == apiDefs::ConfigType::AmneziaPremiumV2
|
||||||
|
|| m_accountInfoData.configType == apiDefs::ConfigType::ExternalPremium;
|
||||||
}
|
}
|
||||||
case HasExpiredWorkerRole: {
|
case HasExpiredWorkerRole: {
|
||||||
for (int i = 0; i < m_issuedConfigsInfo.size(); i++) {
|
for (int i = 0; i < m_issuedConfigsInfo.size(); i++) {
|
||||||
|
@ -93,6 +97,8 @@ void ApiAccountInfoModel::updateModel(const QJsonObject &accountInfoObject, cons
|
||||||
|
|
||||||
m_accountInfoData = accountInfoData;
|
m_accountInfoData = accountInfoData;
|
||||||
|
|
||||||
|
m_supportInfo = accountInfoObject.value(apiDefs::key::supportInfo).toObject();
|
||||||
|
|
||||||
endResetModel();
|
endResetModel();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -121,12 +127,27 @@ QJsonArray ApiAccountInfoModel::getIssuedConfigsInfo()
|
||||||
|
|
||||||
QString ApiAccountInfoModel::getTelegramBotLink()
|
QString ApiAccountInfoModel::getTelegramBotLink()
|
||||||
{
|
{
|
||||||
if (m_accountInfoData.configType == apiDefs::ConfigType::AmneziaFreeV3) {
|
return m_supportInfo.value(apiDefs::key::telegram).toString();
|
||||||
return tr("amnezia_free_support_bot");
|
}
|
||||||
} else if (m_accountInfoData.configType == apiDefs::ConfigType::AmneziaPremiumV2) {
|
|
||||||
return tr("amnezia_premium_support_bot");
|
QString ApiAccountInfoModel::getEmailLink()
|
||||||
}
|
{
|
||||||
return "";
|
return m_supportInfo.value(apiDefs::key::email).toString();
|
||||||
|
}
|
||||||
|
|
||||||
|
QString ApiAccountInfoModel::getBillingEmailLink()
|
||||||
|
{
|
||||||
|
return m_supportInfo.value(apiDefs::key::billingEmail).toString();
|
||||||
|
}
|
||||||
|
|
||||||
|
QString ApiAccountInfoModel::getSiteLink()
|
||||||
|
{
|
||||||
|
return m_supportInfo.value(apiDefs::key::websiteName).toString();
|
||||||
|
}
|
||||||
|
|
||||||
|
QString ApiAccountInfoModel::getFullSiteLink()
|
||||||
|
{
|
||||||
|
return m_supportInfo.value(apiDefs::key::website).toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
QHash<int, QByteArray> ApiAccountInfoModel::roleNames() const
|
QHash<int, QByteArray> ApiAccountInfoModel::roleNames() const
|
||||||
|
|
|
@ -33,7 +33,12 @@ public slots:
|
||||||
|
|
||||||
QJsonArray getAvailableCountries();
|
QJsonArray getAvailableCountries();
|
||||||
QJsonArray getIssuedConfigsInfo();
|
QJsonArray getIssuedConfigsInfo();
|
||||||
|
|
||||||
QString getTelegramBotLink();
|
QString getTelegramBotLink();
|
||||||
|
QString getEmailLink();
|
||||||
|
QString getBillingEmailLink();
|
||||||
|
QString getSiteLink();
|
||||||
|
QString getFullSiteLink();
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
QHash<int, QByteArray> roleNames() const override;
|
QHash<int, QByteArray> roleNames() const override;
|
||||||
|
@ -51,6 +56,7 @@ private:
|
||||||
AccountInfoData m_accountInfoData;
|
AccountInfoData m_accountInfoData;
|
||||||
QJsonArray m_availableCountries;
|
QJsonArray m_availableCountries;
|
||||||
QJsonArray m_issuedConfigsInfo;
|
QJsonArray m_issuedConfigsInfo;
|
||||||
|
QJsonObject m_supportInfo;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // APIACCOUNTINFOMODEL_H
|
#endif // APIACCOUNTINFOMODEL_H
|
||||||
|
|
|
@ -28,24 +28,24 @@ PageType {
|
||||||
id: techSupport
|
id: techSupport
|
||||||
|
|
||||||
readonly property string title: qsTr("Email")
|
readonly property string title: qsTr("Email")
|
||||||
readonly property string description: qsTr("support@amnezia.org")
|
readonly property string description: ApiAccountInfoModel.getEmailLink()
|
||||||
readonly property string link: "mailto:support@amnezia.org"
|
readonly property string link: "mailto:" + ApiAccountInfoModel.getEmailLink()
|
||||||
}
|
}
|
||||||
|
|
||||||
QtObject {
|
QtObject {
|
||||||
id: paymentSupport
|
id: paymentSupport
|
||||||
|
|
||||||
readonly property string title: qsTr("Email Billing & Orders")
|
readonly property string title: qsTr("Email Billing & Orders")
|
||||||
readonly property string description: qsTr("help@vpnpay.io")
|
readonly property string description: ApiAccountInfoModel.getBillingEmailLink()
|
||||||
readonly property string link: "mailto:help@vpnpay.io"
|
readonly property string link: "mailto:" + ApiAccountInfoModel.getBillingEmailLink()
|
||||||
}
|
}
|
||||||
|
|
||||||
QtObject {
|
QtObject {
|
||||||
id: site
|
id: site
|
||||||
|
|
||||||
readonly property string title: qsTr("Website")
|
readonly property string title: qsTr("Website")
|
||||||
readonly property string description: qsTr("amnezia.org")
|
readonly property string description: ApiAccountInfoModel.getSiteLink()
|
||||||
readonly property string link: LanguageModel.getCurrentSiteUrl()
|
readonly property string link: ApiAccountInfoModel.getFullSiteLink()
|
||||||
}
|
}
|
||||||
|
|
||||||
property list<QtObject> supportModel: [
|
property list<QtObject> supportModel: [
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue