catching any potential errors whilst download/exporting the notification image, will allow us to continue to show the notifications

This commit is contained in:
Adam Brown 2021-11-03 15:44:58 +00:00
parent 8cc68e16d2
commit a37ff83fdc
1 changed files with 9 additions and 5 deletions

View File

@ -208,11 +208,15 @@ class NotifiableEventResolver @Inject constructor(
}
private suspend fun TimelineEvent.downloadAndExportImage(session: Session): Uri? {
return getLastMessageContent()?.takeAs<MessageWithAttachmentContent>()?.let { imageMessage ->
return kotlin.runCatching {
getLastMessageContent()?.takeAs<MessageWithAttachmentContent>()?.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? {