mirror of
https://git.selfprivacy.org/kherel/selfprivacy.org.app.git
synced 2025-01-11 18:39:45 +00:00
Fix dkim runtime exception
This commit is contained in:
parent
d168845b98
commit
62929a4839
|
@ -625,38 +625,25 @@ class ServerApi extends ApiMap {
|
|||
}
|
||||
}
|
||||
|
||||
Future<String> getDkim() async {
|
||||
Future<String?> getDkim() async {
|
||||
Response response;
|
||||
|
||||
String? dkim;
|
||||
final Dio client = await getClient();
|
||||
try {
|
||||
response = await client.get('/services/mailserver/dkim');
|
||||
} on DioError catch (e) {
|
||||
print(e.message);
|
||||
throw Exception('No DKIM key found');
|
||||
} finally {
|
||||
close(client);
|
||||
}
|
||||
|
||||
if (response.statusCode == null) {
|
||||
throw Exception('No DKIM key found');
|
||||
}
|
||||
|
||||
if (response.statusCode == HttpStatus.notFound || response.data == null) {
|
||||
throw Exception('No DKIM key found');
|
||||
}
|
||||
|
||||
if (response.statusCode != HttpStatus.ok) {
|
||||
throw Exception('No DKIM key found');
|
||||
}
|
||||
|
||||
final Codec<String, String> base64toString = utf8.fuse(base64);
|
||||
|
||||
return base64toString
|
||||
dkim = base64toString
|
||||
.decode(response.data)
|
||||
.split('(')[1]
|
||||
.split(')')[0]
|
||||
.replaceAll('"', '');
|
||||
} on DioError catch (e) {
|
||||
print(e.message);
|
||||
} finally {
|
||||
close(client);
|
||||
}
|
||||
|
||||
return dkim;
|
||||
}
|
||||
|
||||
Future<ApiResponse<RecoveryKeyStatus?>> getRecoveryTokenStatus() async {
|
||||
|
|
|
@ -139,7 +139,7 @@ class DnsRecordsCubit
|
|||
final String? ipAddress,
|
||||
final String? dkimPublicKey,
|
||||
) {
|
||||
if (domainName == null || ipAddress == null || dkimPublicKey == null) {
|
||||
if (domainName == null || ipAddress == null) {
|
||||
return [];
|
||||
}
|
||||
return [
|
||||
|
@ -204,6 +204,7 @@ class DnsRecordsCubit
|
|||
type: 'TXT',
|
||||
category: DnsRecordsCategory.email,
|
||||
),
|
||||
if (dkimPublicKey != null)
|
||||
DesiredDnsRecord(
|
||||
name: 'selector._domainkey.$domainName',
|
||||
content: dkimPublicKey,
|
||||
|
|
|
@ -398,7 +398,7 @@ class ServerInstallationRepository {
|
|||
|
||||
String dkimRecordString = '';
|
||||
try {
|
||||
dkimRecordString = await api.getDkim();
|
||||
dkimRecordString = (await api.getDkim())!;
|
||||
} catch (e) {
|
||||
print(e);
|
||||
rethrow;
|
||||
|
|
Loading…
Reference in a new issue