From a37ff83fdcd69832bec4da321b249c8b2f41b667 Mon Sep 17 00:00:00 2001 From: Adam Brown Date: Wed, 3 Nov 2021 15:44:58 +0000 Subject: [PATCH] catching any potential errors whilst download/exporting the notification image, will allow us to continue to show the notifications --- .../notifications/NotifiableEventResolver.kt | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/vector/src/main/java/im/vector/app/features/notifications/NotifiableEventResolver.kt b/vector/src/main/java/im/vector/app/features/notifications/NotifiableEventResolver.kt index 951b593358..23f9fc307b 100644 --- a/vector/src/main/java/im/vector/app/features/notifications/NotifiableEventResolver.kt +++ b/vector/src/main/java/im/vector/app/features/notifications/NotifiableEventResolver.kt @@ -208,11 +208,15 @@ class NotifiableEventResolver @Inject constructor( } private suspend fun TimelineEvent.downloadAndExportImage(session: Session): Uri? { - return getLastMessageContent()?.takeAs()?.let { imageMessage -> - val fileService = session.fileService() - fileService.downloadFile(imageMessage) - fileService.getTemporarySharableURI(imageMessage) - } + return kotlin.runCatching { + getLastMessageContent()?.takeAs()?.let { imageMessage -> + val fileService = session.fileService() + fileService.downloadFile(imageMessage) + fileService.getTemporarySharableURI(imageMessage) + } + }.onFailure { + Timber.e(it, "Failed to download and export image for notification") + }.getOrNull() } private fun resolveStateRoomEvent(event: Event, session: Session, canBeReplaced: Boolean, isNoisy: Boolean): NotifiableEvent? {