Open Outbox from 'send failed' notification (#5887)

This commit is contained in:
parkerfath 2022-01-27 18:33:06 -08:00 committed by GitHub
parent cfc4c0bb71
commit 1265d0724b
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 15 additions and 4 deletions

View file

@ -16,9 +16,18 @@ internal class SendFailedNotificationController(
val text = ExceptionHelper.getRootCauseMessage(exception)
val notificationId = NotificationIds.getSendFailedNotificationId(account)
val folderListPendingIntent = actionBuilder.createViewFolderListPendingIntent(
account, notificationId
)
val pendingIntent = account.outboxFolderId.let { outboxFolderId ->
if (outboxFolderId != null) {
actionBuilder.createViewFolderPendingIntent(
account, outboxFolderId, notificationId
)
} else {
actionBuilder.createViewFolderListPendingIntent(
account, notificationId
)
}
}
val notificationBuilder = notificationHelper
.createNotificationBuilder(account, NotificationChannelManager.ChannelType.MISCELLANEOUS)
@ -29,7 +38,7 @@ internal class SendFailedNotificationController(
.setTicker(title)
.setContentTitle(title)
.setContentText(text)
.setContentIntent(folderListPendingIntent)
.setContentIntent(pendingIntent)
.setStyle(NotificationCompat.BigTextStyle().bigText(text))
.setPublicVersion(createLockScreenNotification(account))
.setCategory(NotificationCompat.CATEGORY_ERROR)

View file

@ -10,6 +10,7 @@ import com.fsck.k9.RobolectricTest
import com.fsck.k9.testing.MockHelper.mockBuilder
import org.junit.Test
import org.mockito.ArgumentMatchers.anyInt
import org.mockito.ArgumentMatchers.anyLong
import org.mockito.Mockito.verify
import org.mockito.kotlin.any
import org.mockito.kotlin.doReturn
@ -88,6 +89,7 @@ class SendFailedNotificationControllerTest : RobolectricTest() {
private fun createActionBuilder(contentIntent: PendingIntent): NotificationActionCreator {
return mock {
on { createViewFolderListPendingIntent(any(), anyInt()) } doReturn contentIntent
on { createViewFolderPendingIntent(any(), anyLong(), anyInt()) } doReturn contentIntent
}
}
}