mirror of
https://git.selfprivacy.org/kherel/selfprivacy.org.app.git
synced 2025-01-23 09:16:54 +00:00
chore: Move domain list getter to dns provider layer for desec
This commit is contained in:
parent
4bb26559aa
commit
eebbf98349
|
@ -181,25 +181,35 @@ class DesecApi extends DnsProviderApi {
|
||||||
}
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Future<List<String>> domainList() async {
|
Future<GenericResult<List>> getDomains() async {
|
||||||
List<String> domains = [];
|
List domains = [];
|
||||||
|
|
||||||
|
late final Response? response;
|
||||||
final Dio client = await getClient();
|
final Dio client = await getClient();
|
||||||
try {
|
try {
|
||||||
final Response response = await client.get(
|
response = await client.get(
|
||||||
'',
|
'',
|
||||||
);
|
);
|
||||||
await Future.delayed(const Duration(seconds: 1));
|
await Future.delayed(const Duration(seconds: 1));
|
||||||
domains = response.data
|
domains = response.data;
|
||||||
.map<String>((final el) => el['name'] as String)
|
|
||||||
.toList();
|
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
print(e);
|
print(e);
|
||||||
|
return GenericResult(
|
||||||
|
success: false,
|
||||||
|
data: domains,
|
||||||
|
code: response?.statusCode,
|
||||||
|
message: response?.statusMessage,
|
||||||
|
);
|
||||||
} finally {
|
} finally {
|
||||||
close(client);
|
close(client);
|
||||||
}
|
}
|
||||||
|
|
||||||
return domains;
|
return GenericResult(
|
||||||
|
success: true,
|
||||||
|
data: domains,
|
||||||
|
code: response.statusCode,
|
||||||
|
message: response.statusMessage,
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
|
|
|
@ -217,15 +217,11 @@ class DesecDnsProvider extends DnsProvider {
|
||||||
],
|
],
|
||||||
);
|
);
|
||||||
|
|
||||||
if (!result.success) {
|
|
||||||
return GenericResult(
|
return GenericResult(
|
||||||
success: result.success,
|
success: true,
|
||||||
data: null,
|
data: null,
|
||||||
code: result.code,
|
|
||||||
message: result.message,
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
String? extractContent(final DnsRecord record) {
|
String? extractContent(final DnsRecord record) {
|
||||||
String? content = record.content;
|
String? content = record.content;
|
||||||
|
@ -235,4 +231,29 @@ class DesecDnsProvider extends DnsProvider {
|
||||||
|
|
||||||
return content;
|
return content;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
Future<GenericResult<List<String>>> domainList() async {
|
||||||
|
List<String> domains = [];
|
||||||
|
final result = await _adapter.api().getDomains();
|
||||||
|
if (result.data.isEmpty || !result.success) {
|
||||||
|
return GenericResult(
|
||||||
|
success: result.success,
|
||||||
|
data: domains,
|
||||||
|
code: result.code,
|
||||||
|
message: result.message,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
domains = result.data
|
||||||
|
.map<String>(
|
||||||
|
(final el) => el['name'] as String,
|
||||||
|
)
|
||||||
|
.toList();
|
||||||
|
|
||||||
|
return GenericResult(
|
||||||
|
success: true,
|
||||||
|
data: domains,
|
||||||
|
);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue