mirror of
https://git.selfprivacy.org/kherel/selfprivacy.org.app.git
synced 2025-01-09 01:21:14 +00:00
refactor: Remove low level ApiController and replace Dns interfaces
This commit is contained in:
parent
5cbf399a58
commit
72a04a54b3
|
@ -1,21 +0,0 @@
|
||||||
import 'package:selfprivacy/logic/api_maps/rest_maps/api_factory_creator.dart';
|
|
||||||
import 'package:selfprivacy/logic/providers/provider_settings.dart';
|
|
||||||
import 'package:selfprivacy/logic/api_maps/rest_maps/dns_providers/dns_provider_factory.dart';
|
|
||||||
|
|
||||||
class ApiController {
|
|
||||||
static DnsProviderApiFactory? get currentDnsProviderApiFactory =>
|
|
||||||
_dnsProviderApiFactory;
|
|
||||||
|
|
||||||
static void initDnsProviderApiFactory(
|
|
||||||
final DnsProviderSettings settings,
|
|
||||||
) {
|
|
||||||
_dnsProviderApiFactory =
|
|
||||||
ApiFactoryCreator.createDnsProviderApiFactory(settings);
|
|
||||||
}
|
|
||||||
|
|
||||||
static void clearProviderApiFactories() {
|
|
||||||
_dnsProviderApiFactory = null;
|
|
||||||
}
|
|
||||||
|
|
||||||
static DnsProviderApiFactory? _dnsProviderApiFactory;
|
|
||||||
}
|
|
|
@ -1,57 +0,0 @@
|
||||||
import 'package:selfprivacy/logic/providers/provider_settings.dart';
|
|
||||||
import 'package:selfprivacy/logic/api_maps/rest_maps/dns_providers/cloudflare/cloudflare_factory.dart';
|
|
||||||
import 'package:selfprivacy/logic/api_maps/rest_maps/dns_providers/digital_ocean_dns/digital_ocean_dns_factory.dart';
|
|
||||||
import 'package:selfprivacy/logic/api_maps/rest_maps/dns_providers/dns_provider_factory.dart';
|
|
||||||
import 'package:selfprivacy/logic/api_maps/rest_maps/server_providers/digital_ocean/digital_ocean_api_factory.dart';
|
|
||||||
import 'package:selfprivacy/logic/api_maps/rest_maps/server_providers/hetzner/hetzner_api_factory.dart';
|
|
||||||
import 'package:selfprivacy/logic/api_maps/rest_maps/server_providers/server_provider_factory.dart';
|
|
||||||
import 'package:selfprivacy/logic/models/hive/server_details.dart';
|
|
||||||
import 'package:selfprivacy/logic/models/hive/server_domain.dart';
|
|
||||||
|
|
||||||
class UnknownApiProviderException implements Exception {
|
|
||||||
UnknownApiProviderException(this.message);
|
|
||||||
final String message;
|
|
||||||
}
|
|
||||||
|
|
||||||
class ApiFactoryCreator {
|
|
||||||
static ServerProviderApiFactory createServerProviderApiFactory(
|
|
||||||
final ServerProviderSettings settings,
|
|
||||||
) {
|
|
||||||
switch (settings.provider) {
|
|
||||||
case ServerProviderType.hetzner:
|
|
||||||
return HetznerApiFactory(region: settings.location);
|
|
||||||
case ServerProviderType.digitalOcean:
|
|
||||||
return DigitalOceanApiFactory(region: settings.location);
|
|
||||||
case ServerProviderType.unknown:
|
|
||||||
throw UnknownApiProviderException('Unknown server provider');
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
static DnsProviderApiFactory createDnsProviderApiFactory(
|
|
||||||
final DnsProviderSettings settings,
|
|
||||||
) {
|
|
||||||
switch (settings.provider) {
|
|
||||||
case DnsProviderType.cloudflare:
|
|
||||||
return CloudflareApiFactory();
|
|
||||||
case DnsProviderType.digitalOcean:
|
|
||||||
return DigitalOceanDnsApiFactory();
|
|
||||||
case DnsProviderType.unknown:
|
|
||||||
throw UnknownApiProviderException('Unknown DNS provider');
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
class VolumeApiFactoryCreator {
|
|
||||||
static VolumeProviderApiFactory createVolumeProviderApiFactory(
|
|
||||||
final ServerProviderSettings settings,
|
|
||||||
) {
|
|
||||||
switch (settings.provider) {
|
|
||||||
case ServerProviderType.hetzner:
|
|
||||||
return HetznerApiFactory();
|
|
||||||
case ServerProviderType.digitalOcean:
|
|
||||||
return DigitalOceanApiFactory();
|
|
||||||
case ServerProviderType.unknown:
|
|
||||||
throw UnknownApiProviderException('Unknown volume provider');
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -7,7 +7,6 @@ import 'package:selfprivacy/logic/api_maps/rest_maps/server_providers/server_pro
|
||||||
import 'package:selfprivacy/logic/api_maps/staging_options.dart';
|
import 'package:selfprivacy/logic/api_maps/staging_options.dart';
|
||||||
import 'package:selfprivacy/logic/models/disk_size.dart';
|
import 'package:selfprivacy/logic/models/disk_size.dart';
|
||||||
import 'package:selfprivacy/logic/models/hive/user.dart';
|
import 'package:selfprivacy/logic/models/hive/user.dart';
|
||||||
import 'package:selfprivacy/logic/models/price.dart';
|
|
||||||
import 'package:selfprivacy/logic/models/server_provider_location.dart';
|
import 'package:selfprivacy/logic/models/server_provider_location.dart';
|
||||||
import 'package:selfprivacy/utils/password_generator.dart';
|
import 'package:selfprivacy/utils/password_generator.dart';
|
||||||
|
|
||||||
|
|
|
@ -1,11 +1,11 @@
|
||||||
import 'package:cubit_form/cubit_form.dart';
|
import 'package:cubit_form/cubit_form.dart';
|
||||||
import 'package:selfprivacy/logic/api_maps/rest_maps/api_controller.dart';
|
|
||||||
import 'package:selfprivacy/logic/api_maps/rest_maps/dns_providers/dns_provider.dart';
|
import 'package:selfprivacy/logic/api_maps/rest_maps/dns_providers/dns_provider.dart';
|
||||||
import 'package:selfprivacy/logic/cubit/app_config_dependent/authentication_dependend_cubit.dart';
|
import 'package:selfprivacy/logic/cubit/app_config_dependent/authentication_dependend_cubit.dart';
|
||||||
import 'package:selfprivacy/logic/models/hive/server_domain.dart';
|
import 'package:selfprivacy/logic/models/hive/server_domain.dart';
|
||||||
import 'package:selfprivacy/logic/models/json/dns_records.dart';
|
import 'package:selfprivacy/logic/models/json/dns_records.dart';
|
||||||
|
|
||||||
import 'package:selfprivacy/logic/api_maps/graphql_maps/server_api/server_api.dart';
|
import 'package:selfprivacy/logic/api_maps/graphql_maps/server_api/server_api.dart';
|
||||||
|
import 'package:selfprivacy/logic/providers/providers_controller.dart';
|
||||||
import 'package:selfprivacy/utils/network_utils.dart';
|
import 'package:selfprivacy/utils/network_utils.dart';
|
||||||
|
|
||||||
part 'dns_records_state.dart';
|
part 'dns_records_state.dart';
|
||||||
|
@ -25,14 +25,12 @@ class DnsRecordsCubit
|
||||||
emit(
|
emit(
|
||||||
DnsRecordsState(
|
DnsRecordsState(
|
||||||
dnsState: DnsRecordsStatus.refreshing,
|
dnsState: DnsRecordsStatus.refreshing,
|
||||||
dnsRecords: ApiController.currentDnsProviderApiFactory!
|
dnsRecords:
|
||||||
.getDnsProvider()
|
ProvidersController.currentDnsProvider!.getDesiredDnsRecords(
|
||||||
.getDesiredDnsRecords(
|
domainName: serverInstallationCubit.state.serverDomain?.domainName,
|
||||||
domainName:
|
dkimPublicKey: '',
|
||||||
serverInstallationCubit.state.serverDomain?.domainName,
|
ipAddress: '',
|
||||||
dkimPublicKey: '',
|
),
|
||||||
ipAddress: '',
|
|
||||||
),
|
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
|
|
||||||
|
@ -41,20 +39,17 @@ class DnsRecordsCubit
|
||||||
final String? ipAddress =
|
final String? ipAddress =
|
||||||
serverInstallationCubit.state.serverDetails?.ip4;
|
serverInstallationCubit.state.serverDetails?.ip4;
|
||||||
if (domain != null && ipAddress != null) {
|
if (domain != null && ipAddress != null) {
|
||||||
final List<DnsRecord> records = await ApiController
|
final List<DnsRecord> records = await ProvidersController
|
||||||
.currentDnsProviderApiFactory!
|
.currentDnsProvider!
|
||||||
.getDnsProvider()
|
|
||||||
.getDnsRecords(domain: domain);
|
.getDnsRecords(domain: domain);
|
||||||
final String? dkimPublicKey =
|
final String? dkimPublicKey =
|
||||||
extractDkimRecord(await api.getDnsRecords())?.content;
|
extractDkimRecord(await api.getDnsRecords())?.content;
|
||||||
final List<DesiredDnsRecord> desiredRecords = ApiController
|
final List<DesiredDnsRecord> desiredRecords =
|
||||||
.currentDnsProviderApiFactory!
|
ProvidersController.currentDnsProvider!.getDesiredDnsRecords(
|
||||||
.getDnsProvider()
|
domainName: domain.domainName,
|
||||||
.getDesiredDnsRecords(
|
ipAddress: ipAddress,
|
||||||
domainName: domain.domainName,
|
dkimPublicKey: dkimPublicKey,
|
||||||
ipAddress: ipAddress,
|
);
|
||||||
dkimPublicKey: dkimPublicKey,
|
|
||||||
);
|
|
||||||
final List<DesiredDnsRecord> foundRecords = [];
|
final List<DesiredDnsRecord> foundRecords = [];
|
||||||
for (final DesiredDnsRecord desiredRecord in desiredRecords) {
|
for (final DesiredDnsRecord desiredRecord in desiredRecords) {
|
||||||
if (desiredRecord.description == 'record.dkim') {
|
if (desiredRecord.description == 'record.dkim') {
|
||||||
|
@ -128,10 +123,10 @@ class DnsRecordsCubit
|
||||||
emit(state.copyWith(dnsState: DnsRecordsStatus.refreshing));
|
emit(state.copyWith(dnsState: DnsRecordsStatus.refreshing));
|
||||||
final ServerDomain? domain = serverInstallationCubit.state.serverDomain;
|
final ServerDomain? domain = serverInstallationCubit.state.serverDomain;
|
||||||
final String? ipAddress = serverInstallationCubit.state.serverDetails?.ip4;
|
final String? ipAddress = serverInstallationCubit.state.serverDetails?.ip4;
|
||||||
final DnsProviderApi dnsProviderApi =
|
await ProvidersController.currentDnsProvider!.removeSimilarRecords(
|
||||||
ApiController.currentDnsProviderApiFactory!.getDnsProvider();
|
domain: domain!,
|
||||||
await dnsProviderApi.removeSimilarRecords(domain: domain!);
|
);
|
||||||
await dnsProviderApi.createMultipleDnsRecords(
|
await ProvidersController.currentDnsProvider!.createMultipleDnsRecords(
|
||||||
domain: domain,
|
domain: domain,
|
||||||
ip4: ipAddress,
|
ip4: ipAddress,
|
||||||
);
|
);
|
||||||
|
@ -139,7 +134,10 @@ class DnsRecordsCubit
|
||||||
final List<DnsRecord> records = await api.getDnsRecords();
|
final List<DnsRecord> records = await api.getDnsRecords();
|
||||||
final DnsRecord? dkimRecord = extractDkimRecord(records);
|
final DnsRecord? dkimRecord = extractDkimRecord(records);
|
||||||
if (dkimRecord != null) {
|
if (dkimRecord != null) {
|
||||||
await dnsProviderApi.setDnsRecord(dkimRecord, domain);
|
await ProvidersController.currentDnsProvider!.setDnsRecord(
|
||||||
|
dkimRecord,
|
||||||
|
domain,
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
await load();
|
await load();
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
import 'package:cubit_form/cubit_form.dart';
|
import 'package:cubit_form/cubit_form.dart';
|
||||||
import 'package:selfprivacy/logic/api_maps/rest_maps/api_controller.dart';
|
|
||||||
import 'package:selfprivacy/logic/cubit/server_installation/server_installation_cubit.dart';
|
import 'package:selfprivacy/logic/cubit/server_installation/server_installation_cubit.dart';
|
||||||
import 'package:selfprivacy/logic/models/hive/server_domain.dart';
|
import 'package:selfprivacy/logic/models/hive/server_domain.dart';
|
||||||
|
import 'package:selfprivacy/logic/providers/providers_controller.dart';
|
||||||
|
|
||||||
class DomainSetupCubit extends Cubit<DomainSetupState> {
|
class DomainSetupCubit extends Cubit<DomainSetupState> {
|
||||||
DomainSetupCubit(this.serverInstallationCubit) : super(Initial());
|
DomainSetupCubit(this.serverInstallationCubit) : super(Initial());
|
||||||
|
@ -10,9 +10,8 @@ class DomainSetupCubit extends Cubit<DomainSetupState> {
|
||||||
|
|
||||||
Future<void> load() async {
|
Future<void> load() async {
|
||||||
emit(Loading(LoadingTypes.loadingDomain));
|
emit(Loading(LoadingTypes.loadingDomain));
|
||||||
final List<String> list = await ApiController.currentDnsProviderApiFactory!
|
final List<String> list =
|
||||||
.getDnsProvider()
|
await ProvidersController.currentDnsProvider!.domainList();
|
||||||
.domainList();
|
|
||||||
if (list.isEmpty) {
|
if (list.isEmpty) {
|
||||||
emit(Empty());
|
emit(Empty());
|
||||||
} else if (list.length == 1) {
|
} else if (list.length == 1) {
|
||||||
|
@ -28,9 +27,8 @@ class DomainSetupCubit extends Cubit<DomainSetupState> {
|
||||||
|
|
||||||
emit(Loading(LoadingTypes.saving));
|
emit(Loading(LoadingTypes.saving));
|
||||||
|
|
||||||
final String? zoneId = await ApiController.currentDnsProviderApiFactory!
|
final String? zoneId =
|
||||||
.getDnsProvider()
|
await ProvidersController.currentDnsProvider!.getZoneId(domainName);
|
||||||
.getZoneId(domainName);
|
|
||||||
|
|
||||||
if (zoneId != null) {
|
if (zoneId != null) {
|
||||||
final ServerDomain domain = ServerDomain(
|
final ServerDomain domain = ServerDomain(
|
||||||
|
|
|
@ -5,11 +5,9 @@ import 'package:easy_localization/easy_localization.dart';
|
||||||
import 'package:equatable/equatable.dart';
|
import 'package:equatable/equatable.dart';
|
||||||
import 'package:selfprivacy/config/get_it_config.dart';
|
import 'package:selfprivacy/config/get_it_config.dart';
|
||||||
import 'package:selfprivacy/logic/api_maps/graphql_maps/server_api/server_api.dart';
|
import 'package:selfprivacy/logic/api_maps/graphql_maps/server_api/server_api.dart';
|
||||||
import 'package:selfprivacy/logic/api_maps/rest_maps/api_controller.dart';
|
|
||||||
import 'package:selfprivacy/logic/models/callback_dialogue_branching.dart';
|
import 'package:selfprivacy/logic/models/callback_dialogue_branching.dart';
|
||||||
import 'package:selfprivacy/logic/models/launch_installation_data.dart';
|
import 'package:selfprivacy/logic/models/launch_installation_data.dart';
|
||||||
import 'package:selfprivacy/logic/providers/provider_settings.dart';
|
import 'package:selfprivacy/logic/providers/provider_settings.dart';
|
||||||
import 'package:selfprivacy/logic/api_maps/rest_maps/dns_providers/dns_provider_api_settings.dart';
|
|
||||||
import 'package:selfprivacy/logic/providers/providers_controller.dart';
|
import 'package:selfprivacy/logic/providers/providers_controller.dart';
|
||||||
import 'package:selfprivacy/logic/models/hive/backblaze_credential.dart';
|
import 'package:selfprivacy/logic/models/hive/backblaze_credential.dart';
|
||||||
import 'package:selfprivacy/logic/models/hive/server_details.dart';
|
import 'package:selfprivacy/logic/models/hive/server_details.dart';
|
||||||
|
@ -68,7 +66,7 @@ class ServerInstallationCubit extends Cubit<ServerInstallationState> {
|
||||||
|
|
||||||
void setDnsProviderType(final DnsProviderType providerType) async {
|
void setDnsProviderType(final DnsProviderType providerType) async {
|
||||||
await repository.saveDnsProviderType(providerType);
|
await repository.saveDnsProviderType(providerType);
|
||||||
ApiController.initDnsProviderApiFactory(
|
ProvidersController.initDnsProvider(
|
||||||
DnsProviderSettings(
|
DnsProviderSettings(
|
||||||
provider: providerType,
|
provider: providerType,
|
||||||
),
|
),
|
||||||
|
@ -97,11 +95,9 @@ class ServerInstallationCubit extends Cubit<ServerInstallationState> {
|
||||||
final String providerToken,
|
final String providerToken,
|
||||||
) async {
|
) async {
|
||||||
final GenericResult<bool> apiResponse =
|
final GenericResult<bool> apiResponse =
|
||||||
await ApiController.currentDnsProviderApiFactory!
|
await ProvidersController.currentDnsProvider!.tryInitApiByToken(
|
||||||
.getDnsProvider(
|
providerToken,
|
||||||
settings: const DnsProviderApiSettings(isWithToken: false),
|
);
|
||||||
)
|
|
||||||
.isApiTokenValid(providerToken);
|
|
||||||
|
|
||||||
if (!apiResponse.success) {
|
if (!apiResponse.success) {
|
||||||
getIt<NavigationService>().showSnackBar(
|
getIt<NavigationService>().showSnackBar(
|
||||||
|
@ -250,8 +246,7 @@ class ServerInstallationCubit extends Cubit<ServerInstallationState> {
|
||||||
serverTypeId: state.serverTypeIdentificator!,
|
serverTypeId: state.serverTypeIdentificator!,
|
||||||
errorCallback: clearAppConfig,
|
errorCallback: clearAppConfig,
|
||||||
successCallback: onCreateServerSuccess,
|
successCallback: onCreateServerSuccess,
|
||||||
dnsProviderApi:
|
dnsProvider: ProvidersController.currentDnsProvider!,
|
||||||
ApiController.currentDnsProviderApiFactory!.getDnsProvider(),
|
|
||||||
);
|
);
|
||||||
|
|
||||||
final result =
|
final result =
|
||||||
|
@ -754,7 +749,6 @@ class ServerInstallationCubit extends Cubit<ServerInstallationState> {
|
||||||
|
|
||||||
void clearAppConfig() {
|
void clearAppConfig() {
|
||||||
closeTimer();
|
closeTimer();
|
||||||
ApiController.clearProviderApiFactories();
|
|
||||||
ProvidersController.clearProviders();
|
ProvidersController.clearProviders();
|
||||||
repository.clearAppConfig();
|
repository.clearAppConfig();
|
||||||
emit(const ServerInstallationEmpty());
|
emit(const ServerInstallationEmpty());
|
||||||
|
|
|
@ -10,12 +10,10 @@ import 'package:hive/hive.dart';
|
||||||
import 'package:pub_semver/pub_semver.dart';
|
import 'package:pub_semver/pub_semver.dart';
|
||||||
import 'package:selfprivacy/config/get_it_config.dart';
|
import 'package:selfprivacy/config/get_it_config.dart';
|
||||||
import 'package:selfprivacy/config/hive_config.dart';
|
import 'package:selfprivacy/config/hive_config.dart';
|
||||||
import 'package:selfprivacy/logic/api_maps/rest_maps/api_controller.dart';
|
|
||||||
import 'package:selfprivacy/logic/providers/provider_settings.dart';
|
import 'package:selfprivacy/logic/providers/provider_settings.dart';
|
||||||
import 'package:selfprivacy/logic/api_maps/rest_maps/dns_providers/dns_provider.dart';
|
import 'package:selfprivacy/logic/api_maps/rest_maps/dns_providers/dns_provider.dart';
|
||||||
import 'package:selfprivacy/logic/api_maps/rest_maps/dns_providers/dns_provider_api_settings.dart';
|
import 'package:selfprivacy/logic/api_maps/rest_maps/dns_providers/dns_provider_api_settings.dart';
|
||||||
import 'package:selfprivacy/logic/api_maps/graphql_maps/server_api/server_api.dart';
|
import 'package:selfprivacy/logic/api_maps/graphql_maps/server_api/server_api.dart';
|
||||||
import 'package:selfprivacy/logic/api_maps/rest_maps/server_providers/server_provider.dart';
|
|
||||||
import 'package:selfprivacy/logic/cubit/server_installation/server_installation_cubit.dart';
|
import 'package:selfprivacy/logic/cubit/server_installation/server_installation_cubit.dart';
|
||||||
import 'package:selfprivacy/logic/models/hive/backblaze_credential.dart';
|
import 'package:selfprivacy/logic/models/hive/backblaze_credential.dart';
|
||||||
import 'package:selfprivacy/logic/models/hive/server_details.dart';
|
import 'package:selfprivacy/logic/models/hive/server_details.dart';
|
||||||
|
@ -72,7 +70,7 @@ class ServerInstallationRepository {
|
||||||
if (dnsProvider != null ||
|
if (dnsProvider != null ||
|
||||||
(serverDomain != null &&
|
(serverDomain != null &&
|
||||||
serverDomain.provider != ServerProviderType.unknown)) {
|
serverDomain.provider != ServerProviderType.unknown)) {
|
||||||
ApiController.initDnsProviderApiFactory(
|
ProvidersController.initDnsProvider(
|
||||||
DnsProviderSettings(
|
DnsProviderSettings(
|
||||||
provider: dnsProvider ?? serverDomain!.provider,
|
provider: dnsProvider ?? serverDomain!.provider,
|
||||||
),
|
),
|
||||||
|
@ -239,8 +237,6 @@ class ServerInstallationRepository {
|
||||||
final ServerDomain domain, {
|
final ServerDomain domain, {
|
||||||
required final void Function() onCancel,
|
required final void Function() onCancel,
|
||||||
}) async {
|
}) async {
|
||||||
final DnsProviderApi dnsProviderApi =
|
|
||||||
ApiController.currentDnsProviderApiFactory!.getDnsProvider();
|
|
||||||
final serverProvider = ProvidersController.currentServerProvider!;
|
final serverProvider = ProvidersController.currentServerProvider!;
|
||||||
|
|
||||||
void showDomainErrorPopUp(final String error) {
|
void showDomainErrorPopUp(final String error) {
|
||||||
|
@ -259,7 +255,7 @@ class ServerInstallationRepository {
|
||||||
}
|
}
|
||||||
|
|
||||||
final GenericResult removingResult =
|
final GenericResult removingResult =
|
||||||
await dnsProviderApi.removeSimilarRecords(
|
await ProvidersController.currentDnsProvider!.removeSimilarRecords(
|
||||||
ip4: serverDetails.ip4,
|
ip4: serverDetails.ip4,
|
||||||
domain: domain,
|
domain: domain,
|
||||||
);
|
);
|
||||||
|
@ -272,8 +268,9 @@ class ServerInstallationRepository {
|
||||||
bool createdSuccessfully = false;
|
bool createdSuccessfully = false;
|
||||||
String errorMessage = 'domain.error'.tr();
|
String errorMessage = 'domain.error'.tr();
|
||||||
try {
|
try {
|
||||||
final GenericResult createResult =
|
final GenericResult createResult = await ProvidersController
|
||||||
await dnsProviderApi.createMultipleDnsRecords(
|
.currentDnsProvider!
|
||||||
|
.createMultipleDnsRecords(
|
||||||
ip4: serverDetails.ip4,
|
ip4: serverDetails.ip4,
|
||||||
domain: domain,
|
domain: domain,
|
||||||
);
|
);
|
||||||
|
@ -293,8 +290,6 @@ class ServerInstallationRepository {
|
||||||
}
|
}
|
||||||
|
|
||||||
Future<void> createDkimRecord(final ServerDomain cloudFlareDomain) async {
|
Future<void> createDkimRecord(final ServerDomain cloudFlareDomain) async {
|
||||||
final DnsProviderApi dnsProviderApi =
|
|
||||||
ApiController.currentDnsProviderApiFactory!.getDnsProvider();
|
|
||||||
final ServerApi api = ServerApi();
|
final ServerApi api = ServerApi();
|
||||||
|
|
||||||
late DnsRecord record;
|
late DnsRecord record;
|
||||||
|
@ -305,7 +300,10 @@ class ServerInstallationRepository {
|
||||||
rethrow;
|
rethrow;
|
||||||
}
|
}
|
||||||
|
|
||||||
await dnsProviderApi.setDnsRecord(record, cloudFlareDomain);
|
await ProvidersController.currentDnsProvider!.setDnsRecord(
|
||||||
|
record,
|
||||||
|
cloudFlareDomain,
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
Future<bool> isHttpServerWorking() async {
|
Future<bool> isHttpServerWorking() async {
|
||||||
|
@ -677,9 +675,8 @@ class ServerInstallationRepository {
|
||||||
await box.put(BNames.isLoading, false);
|
await box.put(BNames.isLoading, false);
|
||||||
await box.put(BNames.serverDetails, null);
|
await box.put(BNames.serverDetails, null);
|
||||||
|
|
||||||
final GenericResult<void> removalResult = await ApiController
|
final GenericResult<void> removalResult = await ProvidersController
|
||||||
.currentDnsProviderApiFactory!
|
.currentDnsProvider!
|
||||||
.getDnsProvider()
|
|
||||||
.removeSimilarRecords(domain: serverDomain);
|
.removeSimilarRecords(domain: serverDomain);
|
||||||
|
|
||||||
if (!removalResult.success) {
|
if (!removalResult.success) {
|
||||||
|
|
|
@ -1,14 +1,14 @@
|
||||||
import 'package:selfprivacy/logic/api_maps/rest_maps/dns_providers/dns_provider.dart';
|
|
||||||
import 'package:selfprivacy/logic/models/hive/server_details.dart';
|
import 'package:selfprivacy/logic/models/hive/server_details.dart';
|
||||||
import 'package:selfprivacy/logic/models/hive/server_domain.dart';
|
import 'package:selfprivacy/logic/models/hive/server_domain.dart';
|
||||||
import 'package:selfprivacy/logic/models/hive/user.dart';
|
import 'package:selfprivacy/logic/models/hive/user.dart';
|
||||||
|
import 'package:selfprivacy/logic/providers/dns_providers/dns_provider.dart';
|
||||||
|
|
||||||
class LaunchInstallationData {
|
class LaunchInstallationData {
|
||||||
LaunchInstallationData({
|
LaunchInstallationData({
|
||||||
required this.rootUser,
|
required this.rootUser,
|
||||||
required this.dnsApiToken,
|
required this.dnsApiToken,
|
||||||
required this.dnsProviderType,
|
required this.dnsProviderType,
|
||||||
required this.dnsProviderApi,
|
required this.dnsProvider,
|
||||||
required this.serverDomain,
|
required this.serverDomain,
|
||||||
required this.serverTypeId,
|
required this.serverTypeId,
|
||||||
required this.errorCallback,
|
required this.errorCallback,
|
||||||
|
@ -19,7 +19,7 @@ class LaunchInstallationData {
|
||||||
final String dnsApiToken;
|
final String dnsApiToken;
|
||||||
final ServerDomain serverDomain;
|
final ServerDomain serverDomain;
|
||||||
final DnsProviderType dnsProviderType;
|
final DnsProviderType dnsProviderType;
|
||||||
final DnsProviderApi dnsProviderApi;
|
final DnsProvider dnsProvider;
|
||||||
final String serverTypeId;
|
final String serverTypeId;
|
||||||
final Function() errorCallback;
|
final Function() errorCallback;
|
||||||
final Function(ServerHostingDetails details) successCallback;
|
final Function(ServerHostingDetails details) successCallback;
|
||||||
|
|
|
@ -580,11 +580,11 @@ class HetznerServerProvider extends ServerProvider {
|
||||||
}
|
}
|
||||||
|
|
||||||
await installationData.successCallback(serverDetails);
|
await installationData.successCallback(serverDetails);
|
||||||
await installationData.dnsProviderApi.removeSimilarRecords(
|
await installationData.dnsProvider.removeSimilarRecords(
|
||||||
ip4: serverDetails.ip4,
|
ip4: serverDetails.ip4,
|
||||||
domain: installationData.serverDomain,
|
domain: installationData.serverDomain,
|
||||||
);
|
);
|
||||||
await installationData.dnsProviderApi.createMultipleDnsRecords(
|
await installationData.dnsProvider.createMultipleDnsRecords(
|
||||||
ip4: serverDetails.ip4,
|
ip4: serverDetails.ip4,
|
||||||
domain: installationData.serverDomain,
|
domain: installationData.serverDomain,
|
||||||
);
|
);
|
||||||
|
|
Loading…
Reference in a new issue