Merge pull request #5591 from k9mail/fix_missing_password_check

Fix check for missing incoming/outgoing server credentials
This commit is contained in:
cketti 2021-08-21 19:06:26 +02:00 committed by GitHub
commit 65870fbab2
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 9 additions and 4 deletions

View file

@ -392,7 +392,7 @@ public class MessagingController {
public void refreshFolderListSynchronous(Account account) {
try {
ServerSettings serverSettings = account.getIncomingServerSettings();
if (serverSettings.password == null) {
if (serverSettings.isMissingCredentials()) {
handleAuthenticationFailure(account, true);
return;
}
@ -651,7 +651,7 @@ public class MessagingController {
private void syncFolder(Account account, long folderId, MessagingListener listener, Backend backend) {
ServerSettings serverSettings = account.getIncomingServerSettings();
if (serverSettings.password == null) {
if (serverSettings.isMissingCredentials()) {
handleAuthenticationFailure(account, true);
return;
}
@ -1512,7 +1512,7 @@ public class MessagingController {
boolean wasPermanentFailure = false;
try {
ServerSettings serverSettings = account.getOutgoingServerSettings();
if (serverSettings.password == null) {
if (serverSettings.isMissingCredentials()) {
handleAuthenticationFailure(account, false);
return;
}

View file

@ -39,7 +39,7 @@ class MailSyncWorker(
return Result.success()
}
if (account.incomingServerSettings.password == null) {
if (account.incomingServerSettings.isMissingCredentials) {
Timber.d("Password for this account is missing. Skipping mail sync.")
return Result.success()
}

View file

@ -16,6 +16,11 @@ data class ServerSettings @JvmOverloads constructor(
@JvmField val clientCertificateAlias: String?,
val extra: Map<String, String?> = emptyMap()
) {
val isMissingCredentials: Boolean = when (authenticationType) {
AuthType.EXTERNAL -> clientCertificateAlias == null
else -> password == null
}
init {
require(type == type.toLowerCase(Locale.ROOT)) { "type must be all lower case" }
}