Merge pull request #6283 from thundernest/outbox_logging

Fix error reporting for send failures
This commit is contained in:
cketti 2022-09-08 11:57:29 +02:00 committed by GitHub
commit 0e56eb8072
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -1501,7 +1501,6 @@ public class MessagingController {
@VisibleForTesting
protected void sendPendingMessagesSynchronous(final Account account) {
Exception lastFailure = null;
boolean wasPermanentFailure = false;
try {
if (isAuthenticationProblem(account, false)) {
Timber.d("Authentication will fail. Skip sending messages.");
@ -1551,10 +1550,16 @@ public class MessagingController {
long messageId = message.getDatabaseId();
OutboxState outboxState = outboxStateRepository.getOutboxState(messageId);
if (outboxState.getSendState() != SendState.READY) {
Timber.v("Skipping sending message %s", message.getUid());
notificationController.showSendFailedNotification(account,
new MessagingException(message.getSubject()));
SendState sendState = outboxState.getSendState();
if (sendState != SendState.READY) {
Timber.v("Skipping sending message %s (reason: %s)", message.getUid(),
sendState.getDatabaseName());
if (sendState == SendState.RETRIES_EXCEEDED) {
lastFailure = new MessagingException("Retries exceeded", true);
} else {
lastFailure = new MessagingException(outboxState.getSendError(), true);
}
continue;
}
@ -1587,22 +1592,19 @@ public class MessagingController {
} catch (AuthenticationFailedException e) {
outboxStateRepository.decrementSendAttempts(messageId);
lastFailure = e;
wasPermanentFailure = false;
handleAuthenticationFailure(account, false);
handleSendFailure(account, localFolder, message, e);
} catch (CertificateValidationException e) {
outboxStateRepository.decrementSendAttempts(messageId);
lastFailure = e;
wasPermanentFailure = false;
notifyUserIfCertificateProblem(account, e, false);
handleSendFailure(account, localFolder, message, e);
} catch (MessagingException e) {
lastFailure = e;
wasPermanentFailure = e.isPermanentFailure();
if (wasPermanentFailure) {
if (e.isPermanentFailure()) {
String errorMessage = e.getMessage();
outboxStateRepository.setSendAttemptError(messageId, errorMessage);
} else if (outboxState.getNumberOfSendAttempts() + 1 >= MAX_SEND_ATTEMPTS) {
@ -1612,24 +1614,19 @@ public class MessagingController {
handleSendFailure(account, localFolder, message, e);
} catch (Exception e) {
lastFailure = e;
wasPermanentFailure = true;
handleSendFailure(account, localFolder, message, e);
}
} catch (Exception e) {
lastFailure = e;
wasPermanentFailure = false;
Timber.e(e, "Failed to fetch message for sending");
notifySynchronizeMailboxFailed(account, localFolder, e);
}
}
if (lastFailure != null) {
if (wasPermanentFailure) {
notificationController.showSendFailedNotification(account, lastFailure);
} else {
notificationController.showSendFailedNotification(account, lastFailure);
}
notificationController.showSendFailedNotification(account, lastFailure);
}
} catch (Exception e) {
Timber.v(e, "Failed to send pending messages");