mirror of
https://git.selfprivacy.org/kherel/selfprivacy.org.app.git
synced 2025-03-11 09:14:10 +00:00
fix: Add DNS provider type to provider classes to fix wrong domain type
This commit is contained in:
parent
3a40b5ed32
commit
040fc43e1f
8 changed files with 20 additions and 2 deletions
lib/logic
cubit/forms/setup/initializing
providers
dns_providers
server_providers
|
@ -28,14 +28,15 @@ class DomainSetupCubit extends Cubit<DomainSetupState> {
|
||||||
|
|
||||||
emit(Loading(LoadingTypes.saving));
|
emit(Loading(LoadingTypes.saving));
|
||||||
|
|
||||||
|
final dnsProvider = ProvidersController.currentDnsProvider!;
|
||||||
final GenericResult<String?> zoneIdResult =
|
final GenericResult<String?> zoneIdResult =
|
||||||
await ProvidersController.currentDnsProvider!.getZoneId(domainName);
|
await dnsProvider.getZoneId(domainName);
|
||||||
|
|
||||||
if (zoneIdResult.success || zoneIdResult.data != null) {
|
if (zoneIdResult.success || zoneIdResult.data != null) {
|
||||||
final ServerDomain domain = ServerDomain(
|
final ServerDomain domain = ServerDomain(
|
||||||
domainName: domainName,
|
domainName: domainName,
|
||||||
zoneId: zoneIdResult.data!,
|
zoneId: zoneIdResult.data!,
|
||||||
provider: DnsProviderType.cloudflare,
|
provider: dnsProvider.type,
|
||||||
);
|
);
|
||||||
|
|
||||||
serverInstallationCubit.setDomain(domain);
|
serverInstallationCubit.setDomain(domain);
|
||||||
|
|
|
@ -29,6 +29,9 @@ class CloudflareDnsProvider extends DnsProvider {
|
||||||
|
|
||||||
ApiAdapter _adapter;
|
ApiAdapter _adapter;
|
||||||
|
|
||||||
|
@override
|
||||||
|
DnsProviderType get type => DnsProviderType.cloudflare;
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Future<GenericResult<bool>> tryInitApiByToken(final String token) async {
|
Future<GenericResult<bool>> tryInitApiByToken(final String token) async {
|
||||||
final api = _adapter.api(getInitialized: false);
|
final api = _adapter.api(getInitialized: false);
|
||||||
|
|
|
@ -29,6 +29,9 @@ class DesecDnsProvider extends DnsProvider {
|
||||||
|
|
||||||
ApiAdapter _adapter;
|
ApiAdapter _adapter;
|
||||||
|
|
||||||
|
@override
|
||||||
|
DnsProviderType get type => DnsProviderType.desec;
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Future<GenericResult<bool>> tryInitApiByToken(final String token) async {
|
Future<GenericResult<bool>> tryInitApiByToken(final String token) async {
|
||||||
final api = _adapter.api(getInitialized: false);
|
final api = _adapter.api(getInitialized: false);
|
||||||
|
|
|
@ -29,6 +29,9 @@ class DigitalOceanDnsProvider extends DnsProvider {
|
||||||
|
|
||||||
ApiAdapter _adapter;
|
ApiAdapter _adapter;
|
||||||
|
|
||||||
|
@override
|
||||||
|
DnsProviderType get type => DnsProviderType.digitalOcean;
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Future<GenericResult<bool>> tryInitApiByToken(final String token) async {
|
Future<GenericResult<bool>> tryInitApiByToken(final String token) async {
|
||||||
final api = _adapter.api(getInitialized: false);
|
final api = _adapter.api(getInitialized: false);
|
||||||
|
|
|
@ -5,6 +5,7 @@ import 'package:selfprivacy/logic/models/json/dns_records.dart';
|
||||||
export 'package:selfprivacy/logic/api_maps/generic_result.dart';
|
export 'package:selfprivacy/logic/api_maps/generic_result.dart';
|
||||||
|
|
||||||
abstract class DnsProvider {
|
abstract class DnsProvider {
|
||||||
|
DnsProviderType get type;
|
||||||
Future<GenericResult<bool>> tryInitApiByToken(final String token);
|
Future<GenericResult<bool>> tryInitApiByToken(final String token);
|
||||||
Future<GenericResult<String?>> getZoneId(final String domain);
|
Future<GenericResult<String?>> getZoneId(final String domain);
|
||||||
Future<GenericResult<void>> removeDomainRecords({
|
Future<GenericResult<void>> removeDomainRecords({
|
||||||
|
|
|
@ -46,6 +46,9 @@ class DigitalOceanServerProvider extends ServerProvider {
|
||||||
|
|
||||||
ApiAdapter _adapter;
|
ApiAdapter _adapter;
|
||||||
|
|
||||||
|
@override
|
||||||
|
ServerProviderType get type => ServerProviderType.digitalOcean;
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Future<GenericResult<bool>> trySetServerLocation(
|
Future<GenericResult<bool>> trySetServerLocation(
|
||||||
final String location,
|
final String location,
|
||||||
|
|
|
@ -47,6 +47,9 @@ class HetznerServerProvider extends ServerProvider {
|
||||||
|
|
||||||
ApiAdapter _adapter;
|
ApiAdapter _adapter;
|
||||||
|
|
||||||
|
@override
|
||||||
|
ServerProviderType get type => ServerProviderType.hetzner;
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Future<GenericResult<bool>> trySetServerLocation(
|
Future<GenericResult<bool>> trySetServerLocation(
|
||||||
final String location,
|
final String location,
|
||||||
|
|
|
@ -14,6 +14,7 @@ export 'package:selfprivacy/logic/api_maps/generic_result.dart';
|
||||||
export 'package:selfprivacy/logic/models/launch_installation_data.dart';
|
export 'package:selfprivacy/logic/models/launch_installation_data.dart';
|
||||||
|
|
||||||
abstract class ServerProvider {
|
abstract class ServerProvider {
|
||||||
|
ServerProviderType get type;
|
||||||
Future<GenericResult<List<ServerBasicInfo>>> getServers();
|
Future<GenericResult<List<ServerBasicInfo>>> getServers();
|
||||||
Future<GenericResult<bool>> trySetServerLocation(final String location);
|
Future<GenericResult<bool>> trySetServerLocation(final String location);
|
||||||
Future<GenericResult<bool>> tryInitApiByToken(final String token);
|
Future<GenericResult<bool>> tryInitApiByToken(final String token);
|
||||||
|
|
Loading…
Add table
Reference in a new issue