mirror of
https://github.com/amnezia-vpn/amnezia-client.git
synced 2026-06-22 02:01:08 +07:00
refactor: deactivate api config before remove (#2569)
Co-authored-by: vkamn <vk@amnezia.org>
This commit is contained in:
@@ -679,6 +679,27 @@ void SubscriptionController::removeApiConfig(const QString &serverId)
|
||||
serverConfigUtils::configTypeFromJson(apiV2->toJson()));
|
||||
}
|
||||
|
||||
bool SubscriptionController::removeServer(const QString &serverId)
|
||||
{
|
||||
if (serverId.isEmpty()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!m_serversRepository->apiV2Config(serverId).has_value()) {
|
||||
qWarning().noquote() << "SubscriptionController::removeServer: not an Api V2 server, id" << serverId;
|
||||
return false;
|
||||
}
|
||||
|
||||
const ErrorCode revokeError = deactivateDevice(serverId);
|
||||
if (revokeError != ErrorCode::NoError && revokeError != ErrorCode::ApiNotFoundError) {
|
||||
qWarning().noquote() << "SubscriptionController::removeServer: deactivateDevice failed (error"
|
||||
<< static_cast<int>(revokeError) << "); removing locally anyway.";
|
||||
}
|
||||
|
||||
m_serversRepository->removeServer(serverId);
|
||||
return true;
|
||||
}
|
||||
|
||||
bool SubscriptionController::isApiKeyExpired(const QString &serverId) const
|
||||
{
|
||||
auto apiV2 = m_serversRepository->apiV2Config(serverId);
|
||||
|
||||
@@ -74,6 +74,8 @@ public:
|
||||
|
||||
void removeApiConfig(const QString &serverId);
|
||||
|
||||
bool removeServer(const QString &serverId);
|
||||
|
||||
void setCurrentProtocol(const QString &serverId, const QString &protocolName);
|
||||
bool isVlessProtocol(const QString &serverId) const;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user