refactored to make use of the ServiceType enum throughout backend and frontend for typesafety
This commit is contained in:
@@ -12,7 +12,7 @@ import com.vaessl.app.exception.WrongServiceTypeException;
|
||||
@Service
|
||||
public class ConnectionService {
|
||||
|
||||
private final Map<String, ConnectionProvider> providerRegistry;
|
||||
private final Map<ServiceType, ConnectionProvider> providerRegistry;
|
||||
|
||||
private final ConnectionRepository cRepository;
|
||||
|
||||
@@ -48,7 +48,7 @@ public class ConnectionService {
|
||||
return new LoginResult(saved.getId(), response.expiresAt());
|
||||
}
|
||||
|
||||
public ConnectionStatusResponse getConnectionStatus(String serviceType, Long connectionId) {
|
||||
public ConnectionStatusResponse getConnectionStatus(ServiceType serviceType, Long connectionId) {
|
||||
ConnectionEntity entity = cRepository.findById(connectionId).orElse(null);
|
||||
if (entity == null)
|
||||
return null;
|
||||
@@ -57,7 +57,7 @@ public class ConnectionService {
|
||||
Instant expiresAt = (provider != null) ? provider.getTokenExpiry(entity) : null;
|
||||
boolean connected = expiresAt == null || expiresAt.isAfter(Instant.now());
|
||||
|
||||
return new ConnectionStatusResponse(serviceType, entity.getAppUrl(), entity.getUsername(),
|
||||
return new ConnectionStatusResponse(serviceType.name(), entity.getAppUrl(), entity.getUsername(),
|
||||
expiresAt, connected);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user