refactor: deactivate api config before remove (#2569)

Co-authored-by: vkamn <vk@amnezia.org>
This commit is contained in:
yp
2026-05-15 09:56:09 +03:00
committed by GitHub
parent fd0c773918
commit d0a1af0381
6 changed files with 46 additions and 1 deletions
@@ -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;