Fix old provider server query parameter

serverId was renamed to apiId.
This commit is contained in:
Davide De Rosa 2022-04-26 18:49:34 +02:00
parent 4973a19fda
commit 259a7e18ca
3 changed files with 6 additions and 6 deletions

View File

@ -106,8 +106,8 @@ public class ProviderManager: ObservableObject, RateLimited {
}
// @available(*, deprecated, message: "only use for migration, server is not cached")
public func server(_ name: ProviderName, vpnProtocol: VPNProtocolType, serverId: String) -> ProviderServer? {
serverRepository.server(forProviderWithName: name, vpnProtocol: vpnProtocol, serverId: serverId)
public func server(_ name: ProviderName, vpnProtocol: VPNProtocolType, apiId: String) -> ProviderServer? {
serverRepository.server(forProviderWithName: name, vpnProtocol: vpnProtocol, apiId: apiId)
}
// public func anyServer(forProviderWithName providerName: ProviderName, vpnProtocol: VPNProtocolType, countryCode: String) -> ProviderServer? {

View File

@ -84,11 +84,11 @@ class ServerRepository: Repository {
}
}
func server(forProviderWithName providerName: ProviderName, vpnProtocol: VPNProtocolType, serverId: String) -> ProviderServer? {
func server(forProviderWithName providerName: ProviderName, vpnProtocol: VPNProtocolType, apiId: String) -> ProviderServer? {
let request = CDInfrastructureServer.fetchRequest()
request.predicate = NSPredicate(
format: "serverId == %@ AND category.infrastructure.provider.name == %@ AND category.infrastructure.vpnProtocol == %@",
serverId,
format: "apiId == %@ AND category.infrastructure.provider.name == %@ AND category.infrastructure.vpnProtocol == %@",
apiId,
providerName,
vpnProtocol.rawValue
)

View File

@ -144,7 +144,7 @@ class ProvidersTests: XCTestCase {
func testServerId() async {
await fetchProvider(.nordvpn)
guard let server = manager.server(.nordvpn, vpnProtocol: .openVPN, serverId: "es143") else {
guard let server = manager.server(.nordvpn, vpnProtocol: .openVPN, apiId: "es143") else {
return
}
pp_log.debug(server)